npm / date-fns
date-fns
What changed in date-fns 3 to 4, from its official release notes, upgrade guides and advisories. Also covers @date-fns/tz. Sources checked 2026-11-30.
22 breaking1 deprecations7 new APIs and options4 behavior and defaults6 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initdate-fns 414 changes
Breaking changes 2
CDN source maps were removed from date-fns; users relying on them should switch to @date-fns/cdn.
Breaking type changes affect users explicitly using internal date-fns types; the notes recommend running the type checker after upgrading.
Deprecations 1
CDN scripts are deprecated and will be removed in the next major release; use @date-fns/cdn instead.
New APIs and options 3
Introduces a package for CDN usage that includes CDN source maps.
Time zone support is available via the TZDate class and tz helper function.
Relevant functions accept the context in option to specify the time zone used for calculations; date results use that time zone.
Behavior and default changes 2
Function arguments and Interval endpoints can use different date types or primitives; values are normalized and results use the type inferred from the context or first encountered argument object.
The package is now ESM-first while continuing to support CommonJS, which may affect some environments.
Fixes and other changes 6
Corrects the pt locale so its first day of the week is Sunday.
Fixes month parsing for October, November, and December in the zh-CN locale.
Fixes month parsing for October, November, and December in the zh-HK locale.
Fixes month parsing for October, November, and December in the zh-TW locale.
Restores type definitions that were missing in v4.2.0 due to a TypeScript misconfiguration.
CDN builds now work with jQuery and other tools that expose $, by wrapping the code in an IIFE.
date-fns 326 changes
Breaking changes 20
Intervals are normalized before comparison; invalid interval properties produce false except for the stated inclusive case when the other values are valid and equal.
Functions no longer check the number of passed arguments, delegating this task to type checkers.
Arguments are no longer explicitly converted to target types; conversion is delegated to type checkers.
Constants are no longer exported from the index; import them from date-fns/constants instead.
The package now has a flat structure, with functions and locales available at paths such as node_modules/date-fns/add.mjs and node_modules/date-fns/locale/enUS.mjs.
The eachXOfInterval functions return reversed arrays for reversed intervals and empty arrays for invalid properties; step may be negative, 0, or NaN.
Flow is no longer supported.
Intervals are normalized before comparison, and any Invalid Date property makes the function return 0.
Internet Explorer is no longer supported.
Functions accepting Interval arguments no longer throw for reversed or invalid intervals; they handle them as negative or invalid intervals.
A new function validates intervals, emulating the v2 interval functions behavior.
Negative intervals produce negative durations, invalid interval properties produce an empty object, and zero values are omitted from the result.
Intervals are normalized before comparison; any Invalid Date property makes the function return false.
Locales now use regular functions instead of the UTC version, which may affect code that uses locales directly.
ESM files now use the .mjs extension.
Exports are now named rather than default, so direct imports must use named-import syntax.
The undocumented onlyNumeric option was removed from the nn and sv locales.
Functions use Math.trunc rounding where rounding is required; behavior is configurable per function.
An out-of-range nearestTo option now returns Invalid Date instead of throwing.
TypeScript types have been completely rewritten, so existing TypeScript usage may need adjustment.
New APIs and options 4
All functions that accept date arguments now also accept strings.
differenceInX functions now accept options with a roundingMethod setting; Math.trunc is the default.
The step option is now accepted.
All functions now export options interfaces.
Behavior and default changes 2
Functions accept custom Date extensions and use the arguments' constructor to generate a result of the same class.
The package now supports both ESM and CommonJS, with file exports explicitly defined in package.json.