Current epoch — epochtime.tools · A precision instrument for time
Try:
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 datestrftimePythonJava.NETGoMoment / Day.jsPHPExcel / SheetsMySQLPostgreSQL
Year, 4 digits%Y%Yyyyyyyyy2006YYYYYyyyy%YYYYY
Year, 2 digits%y%yyyyy06YYyyy%yYY
Month number, 2 digits%m%mMMMM01MMmmm%mMM
Month number, no padding%-m%-m*M%M1Mnm%cFMMM
Month name, short%b%bMMMMMMJanMMMMmmm%bMon
Month name, full%B%BMMMMMMMMJanuaryMMMMFmmmm%MFMMonth
Day of month, 2 digits%d%ddddd02DDddd%dDD
Day of month, no padding%-d%-d*d%d2Djd%eFMDD
Day of year, 3 digits%j%jDDD–002DDDD*––%jDDD
Weekday name, short%a%aEEEdddMondddDddd%aDy
Weekday name, full%A%AEEEEddddMondayddddldddd%WFMDay
Weekday number, Monday = 1%u%u–––E*N––ID
Hour 00-23%H%HHHHH15HHHhh%HHH24
Hour 0-23, no padding%-H%-H*H%H–HGh%kFMHH24
Hour 01-12%I%Ihhhh03hhhhh*%hHH12
Hour 1-12, no padding%-I%-I*h%h3hgh*%lFMHH12
Minute, 2 digits%M%Mmmmm04mmimm*%iMI
Second, 2 digits%S%Sssss05sssss%sSS
Milliseconds (3 digits)%3N%f*SSSfff.000*SSSv.000*%f*MS
Microseconds (6 digits)%6N%fSSSSSSffffff.000000*SSSSSS*u.000000*%fUS
Nanoseconds (9 digits)%N%f*SSSSSSSSS–.000000000*SSSSSSSSS*u*.000000000*%f*US*
AM / PM%p%pattPMAAAM/PM%pAM
UTC offset +0530%z%zxxzzz*-0700ZZO––TZHTZM
UTC offset +05:30%:z%:z*xxxzzz-07:00ZP––TZH:TZM
UTC offset, Z for UTC%:z*%:z*XXX%K*Z07:00Z*p––TZH:TZM*
Time zone abbreviation%Z%Zz–MSTz*T––TZ
ISO week number%V%V–––WW*W–%vIW
ISO week-based year%G%G–––GGGG*o–%xIYYY
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. Use yyyy.
  • .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 to h or s. 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 %-d and %f. The no-padding flag works on Linux and macOS but not on Windows, and %f always prints 6 digits.
  • PostgreSQL Month. It pads the name with spaces to nine characters. Use FMMonth for the plain name.
  • MySQL %i. Minutes are %i, not %m, and DATE_FORMAT has no time zone code.
  • Moment.js DD and dd. DD is the day of the month. dd is 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.

Formatting dates in JSON? jsontools.tools formats and validates it.

Last updated: