C# DateTime.ToString formats quick reference

Always useful too quickly see all the format options for DateTime.ToSring(). Republished here thanks to http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm

The quickset’s below. For the rest click the link above.

Pattern Equivalent Format string Example
d MM/dd/yyyy 08/22/2006
D dddd, dd MMMM yyyy Tuesday, 22 August 2006
f0 dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
f1 dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
f2 dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
f3 dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
F dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
g0 MM/dd/yyyy HH:mm 08/22/2006 06:30
g1 MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
g2 MM/dd/yyyy H:mm 08/22/2006 6:30
g3 MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
G MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07
m MMMM dd August 22
r ddd, dd MMM yyyy HH’:’mm’:’ss ‘GMT’ Tue, 22 Aug 2006 06:30:07 GMT
s yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss 2006-08-22T06:30:07
u yyyy’-‘MM’-‘dd HH’:’mm’:’ss’Z’ 2006-08-22 06:30:07Z
U dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
y yyyy MMMM 2006 August

Leave a Reply