Date format translator
Type a date format in one language and get the same format for strftime, Python, Java, .NET, Go, Moment.js, PHP, Excel, MySQL and PostgreSQL, with a live preview of what each one prints. Nothing leaves your browser.
Preview time and timezone
Sample
Previews use English names, and fractions show .123 so you can see the digits. Zone abbreviations vary by system.
One format, ten spellings
Every language writes the same date format differently. The year is %Y in strftime, yyyy in Java, YYYY in Moment.js, Y in PHP and 2006 in Go. Paste a format above, pick the language it is written in (or let the page detect it), and every other spelling appears with a preview of the text it prints. The preview reads each result back with the target language's own rules, so a code that has no equivalent shows up as missing, not as a silent guess.
Format code cheat sheet
Each row is one part of a date. Cells with an asterisk work only on some platforms, versions or plugins. A dash means the language has no code for it. The %-d style flags and %N are GNU and Ruby extensions.
| Part of the date | strftime | Python | Java | .NET | Go | Moment / Day.js | PHP | Excel / Sheets | MySQL | PostgreSQL |
|---|---|---|---|---|---|---|---|---|---|---|
| Year, 4 digits | %Y | %Y | yyyy | yyyy | 2006 | YYYY | Y | yyyy | %Y | YYYY |
| Year, 2 digits | %y | %y | yy | yy | 06 | YY | y | yy | %y | YY |
| Month number, 2 digits | %m | %m | MM | MM | 01 | MM | m | mm | %m | MM |
| Month number, no padding | %-m | %-m* | M | %M | 1 | M | n | m | %c | FMMM |
| Month name, short | %b | %b | MMM | MMM | Jan | MMM | M | mmm | %b | Mon |
| Month name, full | %B | %B | MMMM | MMMM | January | MMMM | F | mmmm | %M | FMMonth |
| Day of month, 2 digits | %d | %d | dd | dd | 02 | DD | d | dd | %d | DD |
| Day of month, no padding | %-d | %-d* | d | %d | 2 | D | j | d | %e | FMDD |
| Day of year, 3 digits | %j | %j | DDD | – | 002 | DDDD* | – | – | %j | DDD |
| Weekday name, short | %a | %a | EEE | ddd | Mon | ddd | D | ddd | %a | Dy |
| Weekday name, full | %A | %A | EEEE | dddd | Monday | dddd | l | dddd | %W | FMDay |
| Weekday number, Monday = 1 | %u | %u | – | – | – | E* | N | – | – | ID |
| Hour 00-23 | %H | %H | HH | HH | 15 | HH | H | hh | %H | HH24 |
| Hour 0-23, no padding | %-H | %-H* | H | %H | – | H | G | h | %k | FMHH24 |
| Hour 01-12 | %I | %I | hh | hh | 03 | hh | h | hh* | %h | HH12 |
| Hour 1-12, no padding | %-I | %-I* | h | %h | 3 | h | g | h* | %l | FMHH12 |
| Minute, 2 digits | %M | %M | mm | mm | 04 | mm | i | mm* | %i | MI |
| Second, 2 digits | %S | %S | ss | ss | 05 | ss | s | ss | %s | SS |
| Milliseconds (3 digits) | %3N | %f* | SSS | fff | .000* | SSS | v | .000* | %f* | MS |
| Microseconds (6 digits) | %6N | %f | SSSSSS | ffffff | .000000* | SSSSSS* | u | .000000* | %f | US |
| Nanoseconds (9 digits) | %N | %f* | SSSSSSSSS | – | .000000000* | SSSSSSSSS* | u* | .000000000* | %f* | US* |
| AM / PM | %p | %p | a | tt | PM | A | A | AM/PM | %p | AM |
| UTC offset +0530 | %z | %z | xx | zzz* | -0700 | ZZ | O | – | – | TZHTZM |
| UTC offset +05:30 | %:z | %:z* | xxx | zzz | -07:00 | Z | P | – | – | TZH:TZM |
| UTC offset, Z for UTC | %:z* | %:z* | XXX | %K* | Z07:00 | Z* | p | – | – | TZH:TZM* |
| Time zone abbreviation | %Z | %Z | z | – | MST | z* | T | – | – | TZ |
| ISO week number | %V | %V | – | – | – | WW* | W | – | %v | IW |
| ISO week-based year | %G | %G | – | – | – | GGGG* | o | – | %x | IYYY |
| Unix seconds | %s | – | – | – | – | X* | U | – | – | – |
Mistakes the translator warns about
- Java
YYYY. It is the week-based year. On 29 December 2025 it prints 2026. Useyyyy. - .NET separators. The
:and/characters are replaced by the current culture's separators. The translator escapes them so the output stays the same everywhere. - Excel
mm. It means minutes only next tohors. Anywhere else it is the month. - Go digits in text. Go layouts have no escape character, so a literal 1, 2, 3, 4, 5 or 0 in your text is read as a date part.
- PHP
z. The day of the year starts at 0, so 1 January is 0. - Python
%-dand%f. The no-padding flag works on Linux and macOS but not on Windows, and%falways prints 6 digits. - PostgreSQL
Month. It pads the name with spaces to nine characters. UseFMMonthfor the plain name. - MySQL
%i. Minutes are%i, not%m, and DATE_FORMAT has no time zone code. - Moment.js
DDanddd.DDis the day of the month.ddis a two-letter weekday name such as Tu.
Questions
What is the difference between yyyy and YYYY?
In Java and .NET, lower-case yyyy is the calendar year. Capital YYYY in Java is the week-based year, which gives the wrong year in the last days of December: 29 December 2025 prints as 2026-12-29. In Moment.js, Day.js and PostgreSQL, capital YYYY is the normal calendar year, and the ISO week year is GGGG or IYYY. In strftime, %Y is the calendar year and %G is the ISO week year.
Why does my Excel format show the month where I wanted minutes?
Excel reads m and mm as months unless they come right after h or hh, or right before s or ss, where they mean minutes. A format such as mm:dd:yyyy shows a month first, while hh:mm:ss shows minutes. The translator warns when a translated format would be read the other way.
Why does Go format dates with 2006-01-02?
Go layouts are written using one reference time, Mon Jan 2 15:04:05 MST 2006. Read as numbers it is 01/02 03:04:05PM 2006 -0700, so the month is 1, the day 2, the hour 3, the minute 4, the second 5, the year 6 and the zone 7. You write the reference time the way you want your dates to look. Go has no escape character, so a literal 1, 2, 3, 4, 5 or 0 in your text is read as a date part.
How do I write milliseconds in each language?
strftime (GNU date and Ruby) %3N, Python %f (always 6 digits), Java SSS, .NET fff, Go .000, Moment.js and Day.js SSS, PHP v, Excel and Google Sheets .000, MySQL %f (always 6 digits), PostgreSQL MS.
Is the format I type sent to a server?
No. The translation and the preview run in your browser with JavaScript, and nothing you type leaves the page.
Official references
Each format dialect follows its own documentation. The translator's output for strftime, Python, Java, Go, Moment.js, Day.js, PHP, Excel and PostgreSQL was also checked by running real code, and .NET and MySQL against their documentation.
- Python: strftime() and strptime() format codes
- Go: time package: layout constants
- Java: DateTimeFormatter patterns
- .NET: Custom date and time format strings
- Moment.js: Display: format
- Day.js: Display: format
- PHP: DateTime::format
- MySQL: DATE_FORMAT()
- PostgreSQL: Data type formatting functions (to_char)
- GNU date: Date conversion specifiers
- Excel: TEXT function
Formatting dates in JSON? jsontools.tools formats and validates it.
Last updated: