Date format converter
Paste a date format string — yyyy-MM-dd, Y-m-d,
%Y-%m-%d, 2006-01-02 — and see what it produces
right now, plus the same pattern written for every other language.
your pattern
the same pattern elsewhere
click a row to copy that pattern
epoch timestamp shortcuts
Why the same letter means different things
Format strings look interchangeable and are not. The clearest trap is
the letter m: in PHP's date() it is the
two-digit month, while in Java, C# and moment it is the
minute — so copying Y-m-d into Java as
y-m-d silently prints the minute where you wanted the month,
and the bug only looks wrong for part of each hour. Java and moment
disagree about case instead: the day of the month is dd in
Java but DD in moment, where DD means day of
year in Java. Translating through the meaning of each field, rather than
letter by letter, is the only reliable way across.
Go's reference time
Go does not use letters at all. A layout is written as the specific
reference instant Mon Jan 2 15:04:05 MST 2006, and each
component you include is matched by its value: 2006 is the
four-digit year, 01 the month, 02 the day,
15 the 24-hour hour, 04 minutes and
05 seconds. The numbers are mnemonic — 1, 2, 3, 4, 5, 6 in
the order month, day, hour, minute, second, year — which is why
2006-01-02 15:04:05 is the Go spelling of
yyyy-MM-dd HH:mm:ss.
Excel's ambiguous m
In Excel custom number formats, m means month
or minute depending on where it sits: directly after an
h, or immediately before an s, it is read as
minutes, and anywhere else as the month. So hh:mm is hours
and minutes while yyyy-mm is year and month, with the same
two letters. This page applies the same rule when reading an Excel
pattern, so the translation to other languages comes out right.
What runs where
The strftime column covers C, Python's strftime, Ruby and
the Unix date command. Java's column matches both
SimpleDateFormat and the newer
DateTimeFormatter, which Kotlin also uses. The moment column
applies to Day.js and most JavaScript formatting libraries that inherited
moment's tokens. Everything is computed in your browser; nothing is sent
anywhere.