ESday project icon

Migrate

Migration guide

Migrate from Moment.js to EsDay

Change imports

Important: EsDay replaces "Moment.js" as well as "Moment Timezone", as timezone functionality is implemented by a plugin.

To migrate to EsDay you have to replace the import statement.

So replace this:

import moment from 'moment';

with this:

import { esday } from 'esday'

Review code

There are really only two things to know when migrating from Moment.js to EsDay:

Here an example for using plugins:

when you want to get the weekday of an EsDay object, you’ll need to import and register the AdvancedFormat plugin.

import { esday } from 'esday'
import localePlugin from 'esday/plugins/locale'
import weekPlugin from 'esday/plugins/week'

esday.extend(localePlugin).extend(weekPlugin)

const dayOfWeek = esday('2026-07-27).weekday()

After migration there will be a few of these plugins.

Important hint

When after migration EsDay does not behave like Moment.js in your program, the most common reason is one or more missing plugins or a sequence of .extend(...) that does not follow the recommendations in the EsDay documentation of the plugins used.

Here an example concerning immutability:

As EsDay objects are immutable, so using an EsDay method that changes the object, you get a new object. So anything like this:

var foo = moment()
foo.add(1, 'day')

must be changed to this:

let foo = esday()
foo = foo.add(1, 'day')

Differences to Moment.js

Reference: Esday uses Moment.js V2.30.1 as api reference.

Migrate from Day.js to EsDay

Day.js uses the same base concepts of immutability and a plugin system like EsDay, so migration is quite easy. The main difference is what method is part of what plugin.

Change imports

To migrate to EsDay you have to replace the import statement.

So replace this:

import dayjs from 'dayjs/esm';

with this:

import { esday } from 'esday'

Differences to Day.js