0

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

2 Answers2

8
Your_Date_Time_Object.ToString("MM")
em70
  • 6,088
  • 6
  • 48
  • 80
0
DateTime date = DateTime.Now;              // Use current date
string format = "MM";                      // Use this format
Console.WriteLine(date.ToString(format));  // Write to console
Kredns
  • 36,461
  • 52
  • 152
  • 203