DUP: http://stackoverflow.com/questions/501460/format-date-in-c
I have a datetime object (initialized), how can I output the month part as MM?
DUP: http://stackoverflow.com/questions/501460/format-date-in-c
I have a datetime object (initialized), how can I output the month part as MM?
DateTime date = DateTime.Now; // Use current date
string format = "MM"; // Use this format
Console.WriteLine(date.ToString(format)); // Write to console
Similar questions exist:
http://stackoverflow.com/questions/501460/format-date-in-c
There's a useful link with a plenitude of examples in one of the answers of the above question as well.