.Net Framework DateTime Formats string

.Net Framework DateTime Formats string

Date time format string Description Example
dDateTime.Now.ToString("d") Short Date 10/24/2021
DDateTime.Now.ToString("D") Long Date Sunday, October 24, 2021
fDateTime.Now.ToString("f") Full DateTime Sunday, October 24, 2021 9:37 AM
FDateTime.Now.ToString("F") Full Long DateTime Sunday, October 24, 2021 9:37:55 AM
GDateTime.Now.ToString("G") General Long DateTime 10/24/2021 9:37:55 AM
gDateTime.Now.ToString("g") General Short DateTime 10/24/2021 9:37 AM
ggDateTime.Now.ToString("gg") Era A.D.
rDateTime.Now.ToString("r") RFC1123 DateTime Sun, 24 Oct 2021 09:37:55 GMT
sDateTime.Now.ToString("s") Sortable DateTime 2021-10-24T09:37:55
uDateTime.Now.ToString("u") Universal Sortable DateTime 2021-10-24 09:37:55Z
UDateTime.Now.ToString("U") Universal Full DateTime Sunday, October 24, 2021 4:37:55 PM
YDateTime.Now.ToString("Y") Month,Year October 2021
yDateTime.Now.ToString("y") Month,Year October 2021
MDateTime.Now.ToString("M") Month,Day October 24
mDateTime.Now.ToString("m") Month,Day October 24
ODateTime.Now.ToString("O") Round-trip DateTime 2021-10-24T09:37:55.2450661-07:00
ddDateTime.Now.ToString("dd") Day 24
dddDateTime.Now.ToString("ddd") Short Day Name Sun
ddddDateTime.Now.ToString("dddd") Full Day Name Sunday
MMDateTime.Now.ToString("MM") 2-digit month 10
MMMDateTime.Now.ToString("MMM") Short Month Name Oct
MMMMDateTime.Now.ToString("MMMM") Full Month Name October
yyyyDateTime.Now.ToString("yyyy") Full Year 2021
yyDateTime.Now.ToString("yy") 2-digit Year 21
MMMM dd, yyyyDateTime.Now.ToString("MMMM dd, yyyy") Custom Date Format October 24, 2021
MMMM d yyyyDateTime.Now.ToString("MMMM d yyyy") Custom Date Format October 24 2021
dd-MMMM-yyyyDateTime.Now.ToString("dd-MMMM-yyyy") Custom Date Format 24-October-2021
dddd MMMM yyyyDateTime.Now.ToString("dddd MMMM yyyy") Custom Date Format Sunday October 2021
ddd-MMMM-yyyyDateTime.Now.ToString("ddd-MMMM-yyyy") Custom Date Format Sun-October-2021
d/M/yyDateTime.Now.ToString("d/M/yy") Custom Date Format 24/10/21
MM-dd-yDateTime.Now.ToString("MM-dd-y") Custom Date Format 10-24-21
MM/dd/yy H:mm:ss:ffDateTime.Now.ToString("MM/dd/yy H:mm:ss:ff") Custom DateTime Format 10/24/21 9:37:55:24
MM/dd/yy hh:mm:ss tt KDateTime.Now.ToString("MM/dd/yy hh:mm:ss tt K") Custom DateTime Format 10/24/21 09:37:55 AM -07:00
MM/dd/yy H:mm:ss:fff zzzDateTime.Now.ToString("MM/dd/yy H:mm:ss:fff zzz") Custom DateTime Format 10/24/21 9:37:55:245 -07:00
HH:mm:ssDateTime.Now.ToString("HH:mm:ss") Custom Time Format 09:37:55
MM/dd/yy H:mm:ss:fff zzzDateTime.Now.ToString("MM/dd/yy H:mm:ss:fff zzz") Custom DateTime Format 10/24/21 9:37:55:245 -07:00
tDateTime.Now.ToString("t") Short Time 9:37 AM
TDateTime.Now.ToString("T") Long Time 9:37:55 AM
hhDateTime.Now.ToString("hh") 2-digit hour 09
HHDateTime.Now.ToString("HH") 2-digit hour(24 hour) 09
mmDateTime.Now.ToString("mm") 2-digit minute 37
ssDateTime.Now.ToString("ss") 2-digit second 55
sDateTime.Now.ToString("s") second digit no leading zero 2021-10-24T09:37:55
fffDateTime.Now.ToString("fff") milliseconds 245
FFFDateTime.Now.ToString("FFF") milliseconds no trailing zero 245
HH:mm:ssDateTime.Now.ToString("HH:mm:ss") Custom Time Format 09:37:55
hh:mm:ss ttDateTime.Now.ToString("hh:mm:ss tt") Custom Time Format 09:37:55 AM
hh:mm:ss:fffDateTime.Now.ToString("hh:mm:ss:fff") Custom Time Format 09:37:55:245
hh:mm:ss:ffDateTime.Now.ToString("hh:mm:ss:ff") Custom Time Format 09:37:55:24
h:m:s:fDateTime.Now.ToString("h:m:s:f") Custom Time Format 9:37:55:2