C# Formatting DateTime to a String
Often times you find yourself needing to convert a DateTime object into a useful string representation. Here are some basic parameters to the DateTime.ToString() method.
MM/dd/yyyy | 08/25/2010 |
dddd, dd MMMM yyyy | Tuesday, 25 August 2010 |
dddd, dd MMMM yyyy | HH:mm Tuesday, 25 August 2010 06:30 |
dddd, dd MMMM yyyy | hh:mm tt Tuesday, 25 August 2010 06:30 AM |
dddd, dd MMMM yyyy | H:mm Tuesday, 25 August 2010 6:30 |
dddd, dd MMMM yyyy | h:mm tt Tuesday, 25 August 2010 6:30 AM |
dddd, dd MMMM yyyy HH:mm:ss | Tuesday, 25 August 2010 06:30:07 |
MM/dd/yyyy HH:mm | 08/25/2010 06:30 |
MM/dd/yyyy hh:mm tt | 08/25/2010 06:30 AM |
MM/dd/yyyy H:mm | 08/25/2010 6:30 |
MM/dd/yyyy h:mm tt | 08/25/2010 6:30 AM |
MM/dd/yyyy h:mm tt | 08/25/2010 6:30 AM |
MM/dd/yyyy h:mm tt | 08/25/2010 6:30 AM |
MM/dd/yyyy HH:mm:ss | 08/25/2010 06:30:07 |
MMMM dd | August 25 |
MMMM dd | August 25 |
yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK | 2010-08-25T06:30:07.7199252-04:00 |
yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK | 2010-08-25T06:30:07.7199252-04:00 |
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' | Tue, 25 Aug 2010 06:30:07 GMT |
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' | Tue, 25 Aug 2010 06:30:07 GMT |
yyyy'-'MM'-'dd'T'HH':'mm':'ss | 2010-08-25T06:30:07 |
HH:mm | 06:30 |
hh:mm tt | 06:30 AM |
H:mm | 6:30 |
h:mm tt | 6:30 AM |
HH:mm:ss | 06:30:07 |
yyyy'-'MM'-'dd HH':'mm':'ss'Z' | 2010-08-25 06:30:07Z |
dddd, dd MMMM yyyy HH:mm:ss | Tuesday, 25 August 2010 06:30:07 |
yyyy MMMM | 2010 August |
yyyy MMMM | 2010 August |
Comments
sell online