Date Formatter
Format any date in 12 patterns including ISO 8601, US, EU, RFC 2822, Unix timestamp and relative.
Reviewed by Aygul Dovletova · Last reviewed
How to Use the Date Formatter
- Pick a date and time in the date/time picker at the top. The picker defaults to "now" so you can see every format populated instantly.
- Scan the 12-row table of outputs: ISO 8601, RFC 2822, US
MM/DD/YYYY, EUDD/MM/YYYYandDD.MM.YYYY, long human-readable ("Monday, January 1, 2024"), short ("Jan 1, 2024"), Unix timestamp in seconds, Unix timestamp in milliseconds, relative ("3 days ago"), and locale-specific variants. - Click the copy button next to any row to grab that string into your clipboard.
- Change the input to update every row at once - the formatter is reactive.
What Runs When You Change the Date
The component takes your date string, parses it into a JavaScript Date object, and then pipes it through twelve formatters in parallel. Most rows use Intl.DateTimeFormat with different options objects - that API is the one honest place in the browser where locale, timezone, and calendar rules actually behave correctly. The ISO 8601 row comes from toISOString(), which is RFC 3339-compliant. The RFC 2822 row comes from toUTCString(), which is the format email and HTTP Date headers specify. The Unix timestamp rows use Math.floor(date.getTime() / 1000) and date.getTime() directly. The "relative" row uses Intl.RelativeTimeFormat, which picks the largest unit that produces a readable phrase ("2 months ago" instead of "61 days ago") - a detail most handwritten solutions get wrong.
Real Situations Where the Right Format Matters
- Dropping a timestamp into a log line, a commit message, or a filename - ISO 8601 is the only choice that sorts correctly as a string.
- Writing the date into an email, invoice, or legal document where the reader's region expects DD/MM or MM/DD; getting it wrong on a contract with a March 5 vs. May 3 ambiguity has caused real litigation.
- Building an HTTP Last-Modified header or a cookie
Expiresattribute, both of which require RFC 2822/IMF-fixdate format. - Passing a value into a database or API that stores
BIGINTUnix milliseconds. - Populating a CSV export for Excel where a bare ISO date gets mangled into "42736" serial numbers unless you quote it.
- Rendering a "posted 3 hours ago" line in a comment thread without pulling in Moment.js or date-fns.
Ambiguities the Formatter Cannot Fix for You
- 01/02/2024 is January 2 in the US, February 1 in the UK, and February 1 with dots in Germany. If the destination is ambiguous, pick ISO 8601 -
2024-02-01has exactly one interpretation everywhere on Earth. - Two-digit years (
01/02/24) are a readability hazard and a Y2K-class bug magnet. Neither MM/DD/YY nor DD/MM/YY is offered here for that reason. - Timezone implied vs. explicit. ISO 8601 with a trailing
Zis UTC; without an offset it is local; "Jan 1, 2024 12:00 PM" could be any of the twenty-four zones currently in use (plus India's UTC+5:30, Nepal's UTC+5:45, and Iran's UTC+3:30). - Non-Gregorian calendars.
Intl.DateTimeFormatsupportscalendar: 'hebrew',islamic-umalqura,japanese,buddhist, and more - this tool sticks to Gregorian to keep the output table manageable, but the browser can do the others if you need them. - "Relative" drifts with time. "3 days ago" becomes wrong tomorrow. Copy the absolute form if you are pasting into a document.
A Quick Tour of the Formats
ISO 8601 (first published 1988, current ISO 8601-1:2019) is the international standard; RFC 3339 is a stricter profile used in internet protocols, notably JSON-Schema date-times and OpenAPI. RFC 2822 (updated by RFC 5322) defines the "Mon, 01 Jan 2024 12:00:00 GMT" shape used in email headers; HTTP reuses a closely related format standardized by RFC 7231 as IMF-fixdate. Unix time dates to the first edition of Unix in 1971 and counts seconds since 1970-01-01T00:00:00Z; it ignores leap seconds and does not care about timezones, which is exactly why servers and databases adopted it. US MM/DD/YYYY is a holdover from hand-written checks; EU DD/MM/YYYY mirrors spoken order ("the 5th of January"); German DD.MM.YYYY uses dots because DIN 5008 said so. Knowing which audience you are writing for decides the right row.
When Native APIs Beat Libraries
For years the default answer was "just use Moment.js." Moment is now legacy (the maintainers themselves recommend moving off it) and it adds ~70 KB gzipped. date-fns is tree-shakable but still overkill for one-shot formatting. Day.js is the modern ~7 KB option with a Moment-like API. However, for the twelve common formats this tool produces, Intl.DateTimeFormat and Date methods in the browser are free, correctly localized, and maintained by the TC39 committee. This page skips the dependency entirely. Where libraries still shine: parsing loose user input ("next Tuesday at 3pm"), differential calendar math ("add 1 business month"), and timezone-aware arithmetic that outlives a single DST transition - the Temporal proposal (Stage 3 at TC39) will eventually cover those natively, but it is not yet shipping in stable browsers.
Frequently Asked Questions
Why does the ISO 8601 output end with a Z?
The trailing Z is the ISO 8601 shorthand for UTC (the "Z" stands for "Zulu time" in military radio phonetics, which was the convention long before computers). It means "this timestamp is expressed in UTC, with zero offset." A string like 2024-01-01T12:00:00+09:00 is the same instant as 2024-01-01T03:00:00Z. The Z form is what JavaScript toISOString() always produces, and it is what RFC 3339 recommends for machine-to-machine data interchange.
Is the Unix timestamp in seconds or milliseconds?
The table shows both. Unix time in classic form is seconds since 1970-01-01T00:00:00Z, which is 10 digits for any date within the next several centuries. JavaScript Date.getTime() returns milliseconds (13 digits) because the language was designed to handle sub-second precision. Databases tend to store seconds (PostgreSQL EPOCH, Unix log files), while Java, JavaScript, and most modern APIs default to milliseconds. Always check which the consumer expects - confusing the two is a silent bug that skews all timestamps by a factor of 1000.
Does the formatter respect my timezone or display UTC?
Rows labelled "local" use your browser timezone as reported by Intl.DateTimeFormat().resolvedOptions().timeZone, which derives from your OS settings. Rows labelled ISO or RFC 2822 are always UTC. The long human-readable row uses local time because that is what you would say out loud ("Monday 3 PM," not "Monday 22:00 UTC"). If you need a specific target zone that is not your own, use the Timezone Converter tool instead.
What does "RFC 2822" actually mean and where would I use it?
RFC 2822 (later updated by RFC 5322) standardises the internet message format - essentially, the headers of an email. The date header looks like "Tue, 10 Sep 2024 14:30:00 +0000" with a weekday abbreviation, day, month name, 4-digit year, 24-hour time, and a numeric offset or GMT. The same format (with a subset of allowed offsets) is used for the HTTP Date header, the Last-Modified header, and the Set-Cookie Expires attribute. If you are hand-crafting any of those, this is the row to copy.
Why is there no "MM/DD/YY" with a two-digit year?
Because two-digit years are the single worst widely-used date format. They caused the entire Y2K remediation effort, they remain legally ambiguous (is "01/02/25" in 1925 or 2025?), and they defeat string sorting. Every output row here uses a 4-digit year. If a legacy system forces you to produce two-digit years, take the 4-digit output and slice the last two characters yourself - owning that choice explicitly is the right posture.
How does the "relative time" row handle the threshold between units?
Intl.RelativeTimeFormat picks the largest unit that produces a whole number at least 1, walking down from years through months, weeks, days, hours, minutes, to seconds. So "45 days ago" becomes "1 month ago" rather than "45 days ago" - matching how humans naturally round. The API also supports localization, so a French user sees "il y a 1 mois." Your browser locale, not the date, drives that language choice.
Does my date ever leave the tab?
No. The Preact island reads the picker value, computes twelve strings with Intl and Date, and writes them into the table. No fetch, no XHR, no beacon. The only network activity on this page after the initial load is the static asset cache-validation that Cloudflare Pages handles for the Astro site itself.
Can I format a date in a calendar other than Gregorian?
Not directly in this tool. The browser can: Intl.DateTimeFormat accepts a calendar option with values like hebrew, islamic-umalqura, persian, japanese, buddhist, and chinese (ICU CLDR-backed). For production use you would pass { calendar: "persian" } to get Jalali calendar output. We stick to Gregorian here to keep the twelve-row output focused and readable; if you have a specific non-Gregorian need, drop into the devtools console and call Intl.DateTimeFormat directly.
Why does my copied ISO string include .000Z and not just Z?
toISOString() always emits millisecond precision, even when the milliseconds are zero. The spec-accurate form is 2024-01-01T12:00:00.000Z. Most parsers accept both, but some strict RFC 3339 validators (for example in certain OpenAPI toolchains) flag the missing subsecond fraction. Keeping the .000 is the safest interoperable choice; strip it only if you know your consumer rejects it.
Can I paste a string in and have it reformatted?
This tool is picker-first, not parser-first. For loose user-entered strings like "next Friday at 3pm" or "23.04.2024 15:30" you need a parser. The JavaScript built-in Date constructor is notoriously lenient-and-wrong on ambiguous input; libraries like date-fns, Luxon, and the upcoming TC39 Temporal proposal give you explicit format strings. If you already have a Unix timestamp, use our Unix Timestamp Converter as the inverse of this page.
More Date & Time
Business Days Calculator
Count business days between two dates excluding weekends and custom holidays.
Open toolCountdown Timer
Set a target date and time, then watch a live countdown showing days, hours, minutes and seconds.
Open toolDate Difference Calculator
Calculate the exact difference between two dates in years, months, days, weeks, hours and minutes.
Open toolPomodoro Timer
25-minute work and 5-minute break cycles with progress bar, session counter and phase tracking.
Open toolStopwatch
Precise online stopwatch with start, stop, reset and lap time recording. Centisecond accuracy.
Open toolTimezone Converter
Convert times between timezones instantly. Supports 28+ world timezones with DST handling.
Open tool