DateTime format string tester

Type a value and a format string to see what DateTime.ToString(format, culture) returns. End the value with Z or an offset to format a DateTimeOffset.

Standard formats

FormatInvariant cultureEnglish (United States)English (United Kingdom)
d03/05/20273/5/202705/03/2027
DFriday, 05 March 2027Friday, March 5, 2027Friday, 5 March 2027
fFriday, 05 March 2027 14:07Friday, March 5, 2027 2:07 PMFriday, 5 March 2027 14:07
FFriday, 05 March 2027 14:07:09Friday, March 5, 2027 2:07:09 PMFriday, 5 March 2027 14:07:09
g03/05/2027 14:073/5/2027 2:07 PM05/03/2027 14:07
G03/05/2027 14:07:093/5/2027 2:07:09 PM05/03/2027 14:07:09
MMarch 05March 55 March
O2027-03-05T14:07:09.04567892027-03-05T14:07:09.04567892027-03-05T14:07:09.0456789
RFri, 05 Mar 2027 14:07:09 GMTFri, 05 Mar 2027 14:07:09 GMTFri, 05 Mar 2027 14:07:09 GMT
s2027-03-05T14:07:092027-03-05T14:07:092027-03-05T14:07:09
t14:072:07 PM14:07
T14:07:092:07:09 PM14:07:09
u2027-03-05 14:07:09Z2027-03-05 14:07:09Z2027-03-05 14:07:09Z
Y2027 MarchMarch 2027March 2027

Common custom formats

FormatResult (invariant)
yyyy-MM-dd2027-03-05
dd/MM/yyyy05/03/2027
MM/dd/yyyy03/05/2027
yyyy-MM-ddTHH:mm:ss.fffffff2027-03-05T14:07:09.0456789
dddd, MMMM d, yyyyFriday, March 5, 2027
HH:mm:ss.fff14:07:09.045
h:mm tt2:07 PM
yyyyMMddHHmmss20270305140709
MMM yyyyMar 2027

Custom specifiers

d / ddDay 5 / 05
ddd / ddddFri / Friday
M / MMMonth 3 / 03
MMM / MMMMMar / March
yy / yyyy27 / 2027
h / hh12-hour 2 / 02
H / HH24-hour 14
m / mmMinute 7 / 07
s / ssSecond 9 / 09
f … fffffffFraction, 1–7 digits
F … FFFFFFFFraction without trailing zeros
ttAM/PM designator
zzzOffset +10:00 (DateTimeOffset)
KOffset of a DateTimeOffset (empty for a plain DateTime here)
'text'Literal text
%dOne-letter custom format

Value used in the tables: 5 March 2027 14:07:09.0456789. Spaces in results are shown as · in the tester.

Formatting durations? Try the TimeSpan format tester.

Questions

Why does "d" give a date but "%d" gives the day?

A format that is a single letter is a standard format (“d” is the short date). Put % in front to use the letter as a custom specifier: “%d” is the day of the month.

Are "/" and ":" literal characters?

“/” and “:” are the culture’s date and time separators, not literal characters. All three cultures here use “/” and “:”. Quote them ('/') to force the literal character.

mm or MM?

mm is minutes, MM is the month. hh is the 12-hour clock and HH the 24-hour clock.

Which .NET version is this checked against?

.NET 10.0.11 on Windows: every format in the tables below and 459 test cases give the same text as ToString in .NET.

More tools

Runs in your browser: nothing you paste is sent anywhere. Not affiliated with Microsoft, the .NET Foundation or the library authors.