Format playground
Get the pattern right the first time
Both dialects, moment/Unicode and strftime. Type a pattern, watch it render live, and check it against the six instants where format bugs hide.
Testing a date pattern before you ship it
A date pattern is a short string of tokens, like YYYY-MM-DD or %d %b %Y, that tells code how to print a date. Type one in and it renders live against the current moment, in whatever time zone you choose.
There are two families of token, and they look alike but mean different things. Moment and Unicode tokens are used by JavaScript libraries, Java and .NET. The strftime tokens, with a percent sign, are used by C, Python, Ruby and PHP. Switch between them with one click. The token list beside the box shows what each one prints, and a click drops it in at your cursor.
The presets are real patterns from logs, APIs and file names. Each is shown against now, so you can start from one that is close and adjust it.
Then check the edge cases. Most format bugs only show up on a leap day, at midnight, at noon, in the last days of December, or with fractions of a second. The page prints your pattern against each of those moments, so a bug shows up here instead of in production.
Questions people ask
What is the difference between YYYY and yyyy?
In moment, YYYY is the calendar year. In Unicode patterns, used by Java and many others, yyyy is the calendar year and YYYY is the week-based year. The two differ for a few days around New Year, which is a classic bug.
Why does my pattern show the wrong hour at noon?
You are probably using a 12-hour token without an AM or PM marker, or a 24-hour token where you meant 12. Look at the noon and midnight rows in the edge-case table to see which.
Is mm minutes or months?
In moment and Unicode patterns, mm is minutes and MM is months. In strftime, %M is minutes and %m is the month. Mixing them up is one of the most common date bugs there is.
Can I share a pattern?
Yes. The pattern, the dialect, the instant and the zone are all kept in the address bar, so a copied link opens on the same result.