Format Codes

Date/Time

Year

Format CodeMeaning
yYear, no leading zero (e.g. 2001 would be 1)
yyYear, leading zero (e.g. 2001 would be 01)
yyyYear, (e.g. 2001 would be 2001)
yyyyYear, (e.g. 2001 would be 2001)

Month

Format CodeMeaning
MMonth number
MMMonth number with leading zero
MMMAbbreviated Month Name (e.g. Dec)
MMMMFull month name (e.g. December)

Day of Month

Format CodeMeaning
dday of the month, no leading zero
ddday of the month, with a leading zero

Day of Week

Format CodeMeaning
dddRepresents the abbreviated name of the day of the week (Mon, Tue, Wed, etc.)
ddddRepresents the full name of the day of the week (Monday, Tuesday, etc.)

Hour

Format CodeMeaning
h12-hour clock hour (e.g. 7)
hh12-hour clock, with a leading 0 (e.g. 07)
H24-hour clock hour (e.g. 19)
HH24-hour clock hour, with a leading 0 (e.g. 19)

Minutes

Format CodeMeaning
mMinutes
mmMinutes with a leading zero

Seconds

Format CodeMeaning
sSeconds
ssSeconds with leading zero

Fractional Seconds

Format CodeMeaning
ftenths of a second
ffhundredths of a second
fffmilliseconds
ffff1ten thousandths of a second1
fffff1hundred thousandths of a second1
ffffff1millionths of a second1
fffffff1ten millionths of a second1
Ftenths of a second, or nothing if zero

1 While it is possible to display the fractions of a second more precise than a millisecond, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.

Meridiem Designator

Format CodeMeaning
tAbbreviated AM / PM (e.g. A or P)
ttAM / PM (e.g. AM or PM)

Time Zone

Format CodeMeaning
Ktime zone (e.g. +05:00)
zsigned offset of the local operating system's time zone from UTC, in hours. (e.g. +6)
zzAs z but with leading zero (e.g. +06)
zzzsigned offset of the local operating system's time zone from UTC, in hours and minutes. (e.g. +06:00)

Delimiters

Format CodeMeaning
:Represents the time separator defined in the current DateTimeFormatInfo..::.TimeSeparator property. This separator is used to differentiate hours, minutes, and seconds.
/Represents the date separator defined in the current DateTimeFormatInfo..::.DateSeparator property. This separator is used to differentiate years, months, and days.
"Represents a quoted string (quotation mark). Displays the literal value of any string between two quotation marks ("). Your application should precede each quotation mark with an escape character (\).
'Represents a quoted string (apostrophe). Displays the literal value of any string between two apostrophe (') characters.