Based on C # datetime, output the month as MM?

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

0


source to share


2 answers


Your_Date_Time_Object.ToString("MM")

      



+8


source


DateTime date = DateTime.Now;              // Use current date
string format = "MM";                      // Use this format
Console.WriteLine(date.ToString(format));  // Write to console

      



0


source







All Articles