Format readable dates with date-fns

A practical review of human-readable date formatting with date-fns: what format, relative and localized output change, and when ISO 8601 text is the safer choice.

date-fns is a JavaScript library of small functions for working with Date values. To make dates readable, it offers several options. The format function uses pattern tokens. Localized tokens pick a regional word order. formatDistance and formatDistanceToNow produce relative phrases such as "3 days ago". formatRelative produces calendar-relative wording. intlFormat hands formatting to the runtime's built-in Intl API. This review looks at whether those transformations keep a date's meaning, readability and practical usability. No hands-on test results were supplied, so the review relies on documented behavior and general principles, and it marks where verification is still needed.

Is it suitable for your use?

Human-readable date-fns output suits dates shown to people in an interface where you control the locale and time zone and keep the original value alongside the display. Its main benefit is explicit wording. A pattern with a spelled-out month avoids numeric strings like 03/04/2026, which US readers take as March 4 and many other readers take as April 3. The decisive tradeoff is that the output is only a display string. It drops precision and time-zone context, and relative phrases start going stale as soon as they are rendered.

Use plain machine-oriented text instead whenever the value will be stored, sorted, parsed, exchanged between systems or pasted into another tool. In those cases, an ISO 8601 string from formatISO is the safer form, with a readable version added only for display.

What the transformation actually changes

Every date-fns formatting function takes a date and returns a new string. The original Date value is not modified. The result is made of ordinary characters, not visual presentation: there is no glyph substitution, mirroring, special Unicode styling or CSS. Text-styling terms like "mirror" or "font" don't apply here. The nearest thing to a reverse step is parse, which turns a string back into a Date. It only works reliably if you know the exact pattern and locale that produced the string.

  • format(date, pattern): exact output controlled by tokens such as MMMM, d and yyyy.
  • Localized tokens (P, PP, PPP, PPPP and their time counterparts): the active locale chooses the order and wording.
  • formatDistance and formatDistanceToNow: approximate relative phrases. The addSuffix option adds "ago" or "in".
  • formatRelative: calendar-relative phrases that name the day relative to a base date.
  • intlFormat: output produced by the runtime's Intl implementation rather than by date-fns patterns.
  • formatISO: machine-readable ISO 8601 text, the plain counterpart to everything above.
import { format, formatDistanceToNow, formatISO } from "date-fns";
import { de } from "date-fns/locale";

const date = new Date(2026, 2, 4); // months are zero-based: March 4, 2026

format(date, "MMMM d, yyyy");          // "March 4, 2026"
format(date, "PPP", { locale: de });  // German long date
formatDistanceToNow(date, { addSuffix: true }); // e.g. "3 days ago"
formatISO(date);                       // ISO 8601 string with offset

Watch the tokens closely. In current versions, yyyy is the calendar year and YYYY is the week-numbering year. Likewise, d is the day of the month and DD is the day of the year. By default, date-fns throws an error for the confusable YYYY, YY, D and DD tokens unless you opt in. This catches a common mistake, but it also means patterns copied from other date libraries may fail or mean something different.

Time zone is the other silent change. format renders the date in the local time zone of whatever environment runs the code, so the same timestamp can show a different day on a server than in a reader's browser. Version 4 added time zone support through a companion package. Whichever approach you use, decide explicitly which zone the reader should see. Output from intlFormat depends on the JavaScript engine, so don't assume identical strings across browsers or Node versions.

Locale affects meaning as well as language. Without a locale option, output is US English. For right-to-left languages, the string's characters are stored in logical order, and display direction is left to the rendering environment. Check how dates appear when embedded in surrounding text of the opposite direction.

Will it stay readable after copying or sharing?

Because the output is plain text, it pastes cleanly into email, chat and documents. Its meaning travels less well. A relative phrase like "2 days ago" becomes wrong once it is pasted somewhere and read later. A time without a zone, such as "3:00 PM", is ambiguous to readers elsewhere. Numeric patterns carry the regional ambiguity described above. Spelled-out months and explicit years survive sharing best.

For accessibility, screen readers announce the text as written, so wording choices matter. Full month names are generally less ambiguous than slash-separated digits. How a particular screen reader voices ordinal suffixes, abbreviated weekdays or locale-specific formats was not tested here, so check that against your own target assistive technologies. In HTML, wrap displayed dates in a time element whose datetime attribute holds the ISO value. That keeps a machine-readable form attached to the human-readable text. Don't put the exact date for a relative phrase only in a hover tooltip, because tooltips are not reliably available to keyboard, touch or assistive technology users.

Formatted strings also behave poorly as data. They sort alphabetically rather than chronologically. A search for "2026-03-04" will not match "March 4, 2026". Users editing a date need a native date input or a strict format, not free-form display text.

  • Keep or provide a plain ISO 8601 equivalent when:
  • the value is stored in a database, file or URL
  • data is exported to spreadsheets, APIs or other systems
  • records need to be sorted, filtered or searched
  • the text may be read long after it was generated, which rules out relative phrases
  • readers span regions or time zones and the exact moment matters

Choosing an approach

Use case | Suggested approach | Watch for
Fixed US-English display | format with an explicit pattern such as MMMM d, yyyy | Server and browser time zones differ
Multilingual interface | Localized tokens with a locale option | Locale bundles must be imported and passed in
Activity feeds and recent events | formatDistanceToNow with addSuffix | Text goes stale; give the exact date accessibly
Storage and data exchange | formatISO | Not meant as reader-facing text
Runtime-native wording | intlFormat | Output varies by engine and version

Gaps in the evidence

No subject-specific tests, measurements or version-by-version comparisons were supplied for this review. The behavior described here reflects documented date-fns functionality and general principles of date handling. It has not been checked in specific destinations, assistive technologies or runtimes. Before relying on exact output in production, check the documentation for the date-fns version you are using and test rendering in the environments your readers use.