0

I have a datetime object (initialized), how can I output the month part as MM?

Tim Cooper
  • 151,519
  • 37
  • 317
  • 271

2 Answers2

8
Your_Date_Time_Object.ToString("MM")
Tim Cooper
  • 151,519
  • 37
  • 317
  • 271
em70
  • 6,058
  • 5
  • 46
  • 80
0
DateTime date = DateTime.Now;              // Use current date
string format = "MM";                      // Use this format
Console.WriteLine(date.ToString(format));  // Write to console
Kredns
  • 35,368
  • 50
  • 149
  • 201