Convert legacy mutable Moment.js operations into pure, tree-shakeable date-fns functions. Reduce JavaScript bundle weight by up to 70KB.
import { format, addDays, differenceInDays, isBefore } from 'date-fns';
const now = moment();
const formatted = format(new Date(), 'YYYY-MM-DD');
const nextWeek = addDays(now, 7);
const isPast = isBefore(nextWeek, now);
const diff = differenceInDays(nextWeek, now);
Unlike Moment.js which mutates date objects in-place, date-fns functions are pure and return new Date instances.
date-fns uses individual named function imports to enable modern tree-shaking and zero bundle bloat.
Paste your JavaScript or TypeScript code utilizing `moment()`.
The migrator replaces chained mutations with pure date-fns functional imports.
Date format tokens (YYYY-MM-DD -> yyyy-MM-dd) are updated to ISO standard tokens.
Export the tree-shakeable code and remove `moment` from your project dependencies.
"scripts": {
"check-deps": "bunx depcheck --ignores=moment"
}Perform identical migration routines across entire directories or repositories in your local terminal:
devflow migrate moment-to-date-fns -i src/utils/date.tsInstantly migrate npm scripts, dependencies, and configurations to Bun. Optimize script execution speeds and strip obsolete transpilations.
Convert Jest test suites, configs, and mocks to Vitest. Share identical Vite configurations and execute tests 4x faster with ESM native workers.