Calendar Date Formatter
Format any calendar date into 20+ output styles including ISO 8601, RFC 2822, Unix timestamp, ordinal, and custom patterns with live preview.
About
Date formatting errors cause silent data corruption across systems. A date written as 01/02/2024 means January 2nd in the US but February 1st in Europe. Database imports fail. API payloads get rejected. Spreadsheet sorting breaks. This tool converts any input date into 20+ standardized output formats - ISO 8601, RFC 2822, Unix epoch seconds, ordinal dates, and fully custom token patterns - eliminating ambiguity. It computes the ISO week number using the algorithm defined in ISO 8601:2004 and calculates the Julian Day Number (JDN) for astronomical cross-referencing.
The custom format engine parses token strings such as YYYY-MM-DD and replaces each token with the corresponding date component. Locale-aware month and weekday names are derived from the browser's Intl.DateTimeFormat API. This tool approximates locale conventions assuming the browser's ICU dataset is complete. Edge cases include leap second ambiguity and the Gregorian calendar's lack of a year zero - the tool handles proleptic Gregorian dates but accuracy degrades for dates before 1582.
Formulas
The ISO week number W is computed per ISO 8601:2004. The algorithm finds the Thursday of the current week and determines its ordinal position within the year:
where ordinal(Thursday) is the day-of-year of the Thursday in the same ISO week as the input date. The Julian Day Number JDN for a Gregorian calendar date is:
where Y = year, M = month (1 - 12), D = day. The Unix timestamp X is:
where t is the date's millisecond value and epoch = January 1, 1970 00:00:00 UTC. Ordinal suffixes follow English rules: 1→st, 2→nd, 3→rd, all others→th, except 11, 12, 13 which take th.
Reference Data
| Token | Description | Example Output |
|---|---|---|
| YYYY | 4-digit year | 2024 |
| YY | 2-digit year | 24 |
| MMMM | Full month name | December |
| MMM | Abbreviated month | Dec |
| MM | Month zero-padded | 01 - 12 |
| M | Month unpadded | 1 - 12 |
| DD | Day zero-padded | 01 - 31 |
| D | Day unpadded | 1 - 31 |
| Do | Day with ordinal suffix | 1st, 2nd, 23rd |
| dddd | Full weekday name | Wednesday |
| ddd | Abbreviated weekday | Wed |
| dd | 2-letter weekday | We |
| d | Day of week (0=Sun) | 0 - 6 |
| HH | Hour 24h zero-padded | 00 - 23 |
| H | Hour 24h unpadded | 0 - 23 |
| hh | Hour 12h zero-padded | 01 - 12 |
| h | Hour 12h unpadded | 1 - 12 |
| mm | Minutes zero-padded | 00 - 59 |
| ss | Seconds zero-padded | 00 - 59 |
| A | AM/PM uppercase | AM, PM |
| a | am/pm lowercase | am, pm |
| X | Unix timestamp (seconds) | 1700000000 |
| x | Unix timestamp (milliseconds) | 1700000000000 |
| W | ISO week number | 1 - 53 |
| WW | ISO week zero-padded | 01 - 53 |
| DDD | Day of year | 1 - 366 |
| Q | Quarter of year | 1 - 4 |
| ZZ | UTC offset | +05:30 |
| Z | UTC offset short | +0530 |