Check date-fns format tokens, parseISO, custom parsing, locale options and protected token warnings before a date contract lands in code.
date-fns is direct and modular, but production mistakes often come from details that look tiny in review: YYYY instead of yyyy, DD instead of dd, a parse format that does not match input, a locale that is missing from the options object or a reference date that changes the parse result. This playground keeps those choices visible.
The evaluator runs in the browser. The page does not send pasted dates, formats or snippets to a backend and does not store history.
Choose a preset, adjust the input, parse mode, format strings, locale and reference date, then inspect output, warnings and a copyable snippet.
Start from an ISO timestamp and inspect a common yyyy-MM-dd HH:mm:ss output.
2026-05-26 09:30:00
2026-05-26T09:30:00.000ZThe parsed Date serialized as ISO. Local rendering may still differ by runtime timezone.
ISO inputCustom parse mode validates the string against the selected parse format.
2026-05-26T09:30:00ZA stable date-fns format useful for contract review.
in about 10 hoursformatDistance from the deterministic reference date.
import { format, formatDistance, parseISO } from 'date-fns';
import { enUS } from 'date-fns/locale/en-US';
const locale = enUS;
const value = parseISO("2026-05-26T09:30:00Z");
const formatted = format(value, "yyyy-MM-dd HH:mm:ss", { locale });
const distance = formatDistance(value, parseISO("2026-05-26T00:00:00.000Z"), { addSuffix: true, locale });date-fns follows Unicode token rules. YYYY and DD are protected because they can mean week-year or day-of-year. For normal calendar output, use yyyy and dd.
Use parseISO for ISO strings. Use parse with a format and reference date when the input is custom, user-facing or imported from a document.
This MVP does not load date-fns-tz or promise IANA timezone conversion. It shows the browser/runtime Date boundary clearly so reviewers do not confuse local output with a scheduling engine.
Date format decisions usually sit next to payload validation, code formatting and another date library. Use the neighboring tools when the contract is broader than one date-fns expression.
No. The MVP intentionally shows the JS Date / ISO boundary and does not load date-fns-tz. Full IANA timezone handling should be a separate tool.
YYYY is a protected week-year token in date-fns. Use yyyy for calendar years unless application code deliberately enables the additional week-year token option.
parse and formatDistance need a stable reference for reproducible examples. A deterministic value keeps docs, tests and review notes from drifting with the current clock.
No. The evaluator runs client-side, does not store history and treats pasted strings as private browser data.