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
| Format | Invariant culture | English (United States) | English (United Kingdom) |
|---|---|---|---|
| d | 03/05/2027 | 3/5/2027 | 05/03/2027 |
| D | Friday, 05 March 2027 | Friday, March 5, 2027 | Friday, 5 March 2027 |
| f | Friday, 05 March 2027 14:07 | Friday, March 5, 2027 2:07 PM | Friday, 5 March 2027 14:07 |
| F | Friday, 05 March 2027 14:07:09 | Friday, March 5, 2027 2:07:09 PM | Friday, 5 March 2027 14:07:09 |
| g | 03/05/2027 14:07 | 3/5/2027 2:07 PM | 05/03/2027 14:07 |
| G | 03/05/2027 14:07:09 | 3/5/2027 2:07:09 PM | 05/03/2027 14:07:09 |
| M | March 05 | March 5 | 5 March |
| O | 2027-03-05T14:07:09.0456789 | 2027-03-05T14:07:09.0456789 | 2027-03-05T14:07:09.0456789 |
| R | Fri, 05 Mar 2027 14:07:09 GMT | Fri, 05 Mar 2027 14:07:09 GMT | Fri, 05 Mar 2027 14:07:09 GMT |
| s | 2027-03-05T14:07:09 | 2027-03-05T14:07:09 | 2027-03-05T14:07:09 |
| t | 14:07 | 2:07 PM | 14:07 |
| T | 14:07:09 | 2:07:09 PM | 14:07:09 |
| u | 2027-03-05 14:07:09Z | 2027-03-05 14:07:09Z | 2027-03-05 14:07:09Z |
| Y | 2027 March | March 2027 | March 2027 |
Common custom formats
| Format | Result (invariant) |
|---|---|
| yyyy-MM-dd | 2027-03-05 |
| dd/MM/yyyy | 05/03/2027 |
| MM/dd/yyyy | 03/05/2027 |
| yyyy-MM-ddTHH:mm:ss.fffffff | 2027-03-05T14:07:09.0456789 |
| dddd, MMMM d, yyyy | Friday, March 5, 2027 |
| HH:mm:ss.fff | 14:07:09.045 |
| h:mm tt | 2:07 PM |
| yyyyMMddHHmmss | 20270305140709 |
| MMM yyyy | Mar 2027 |
Custom specifiers
| d / dd | Day 5 / 05 |
| ddd / dddd | Fri / Friday |
| M / MM | Month 3 / 03 |
| MMM / MMMM | Mar / March |
| yy / yyyy | 27 / 2027 |
| h / hh | 12-hour 2 / 02 |
| H / HH | 24-hour 14 |
| m / mm | Minute 7 / 07 |
| s / ss | Second 9 / 09 |
| f … fffffff | Fraction, 1–7 digits |
| F … FFFFFFF | Fraction without trailing zeros |
| tt | AM/PM designator |
| zzz | Offset +10:00 (DateTimeOffset) |
| K | Offset of a DateTimeOffset (empty for a plain DateTime here) |
| 'text' | Literal text |
| %d | One-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
- Cron expression tester
- appsettings.json ⇄ environment variables
- SQL Server connection string builder
- PostgreSQL connection string builder
- TimeSpan format string tester
- JSON to C# records
Runs in your browser: nothing you paste is sent anywhere. Not affiliated with Microsoft, the .NET Foundation or the library authors.