---
title: "Day.js: A Convenient Alternative to Moment.js for Node.js Consulting"
description: Say goodbye to Moment.js and say hello to Day.js. Learn why we migrated to this lightweight and syntactically similar alternative for Node.js consulting.
image: https://www.bitovi.com/hubfs/Day.js-%20A%20Convenient%20Alternative%20to%20Moment.js%20for%20Node.js%20Consulting.png
---

- ![AI implementation](https://www.bitovi.com/hubfs/AIConsultingIcon.svg)
  
  [AI implementation](https://www.bitovi.com/services/ai-consulting)
- ![Systems engineering](https://www.bitovi.com/hubfs/icon%20-%20backend.svg)
  
  [Systems engineering](https://www.bitovi.com/services/systems-engineering-consulting)
- ![Project Management](https://www.bitovi.com/hubfs/icon%20-%20PM.svg)
  
  [Project Management](https://www.bitovi.com/services/agile-project-management-consulting)
- ![Product Design](https://www.bitovi.com/hubfs/icon%20-%20design.svg)
  
  [Product Design](https://www.bitovi.com/services/product-design-consulting)
- ![Frontend development](https://www.bitovi.com/hubfs/icon%20-%20frontend.svg)
  
  [Frontend development](https://www.bitovi.com/services/frontend-development-consulting)
- [View more
  
  →
  
  ](https://www.bitovi.com/digital-consulting-services)

We're Experts in...

- [JavaScript](https://www.bitovi.com/services/frontend/javascript-consulting)
- [AI training](https://www.bitovi.com/ai-training-for-software-engineers)
- [Angular](https://www.bitovi.com/services/frontend/angular-consulting)
- [Design systems](https://www.bitovi.com/services/axure-figma-migration)
- [React](https://www.bitovi.com/services/frontend/react-consulting)
- [Temporal](https://www.bitovi.com/services/backend/temporal-consulting)
- [React Native](https://www.bitovi.com/services/frontend/react-consulting/react-native)
- [Node.js](https://www.bitovi.com/services/backend/nodejs-consulting)

Showcase

![Yum! Brands](https://www.bitovi.com/hubfs/yum-showcase-link-1.png)

[View case study](https://www.bitovi.com/en/bitovi-yum-case-study)

More Projects

- [![Levi's](https://www.bitovi.com/hubfs/levis.svg)](https://www.bitovi.com/web-application-consulting-work/levis-ecommerce-responsive-redesign)
- [![Christie's International Real Estate](https://www.bitovi.com/hubfs/christies.svg)](https://design.bitovi.com/christies)
- [![BAFS](https://www.bitovi.com/hubfs/bafs.svg)](https://www.bitovi.com/ux-design-consulting/ux-case-studies/bafs-ppp)
- [View more
  
  →
  
  ](https://www.bitovi.com/our-software-consulting-work)

Open Source Tools

We build powerful tools and open source them to support the community.

[See what we've built →](https://www.bitovi.com/open-source)

- [![Blog](https://www.bitovi.com/hubfs/icon%20-%20blog.svg)
  
  BlogWe post about delivering products and solving problems.
  
  ](https://www.bitovi.com/blog)
- [![Partnerships](https://www.bitovi.com/hubfs/Handshake-1.svg)
  
  PartnershipsLearn about Bitovi's technology partners
  
  ](https://www.bitovi.com/partnerships)
- [![Academy](https://www.bitovi.com/hubfs/icon%20-%20academy%20(4).svg)
  
  AcademyFree courses to build delivery skills
  
  ](https://www.bitovi.com/academy)
- [![Open source tools](https://www.bitovi.com/hubfs/icon%20-%20open%20source.svg)
  
  Open source toolsUse or contribute to our community
  
  ](https://www.bitovi.com/open-source)

Let's Connect

- [![Discord](https://www.bitovi.com/hubfs/DiscordLogo.svg)
  
  Discord
  
  ](https://discord.gg/J7ejFsZnJ4)
- [![LinkedIn](https://www.bitovi.com/hubfs/LinkedinLogo.svg)
  
  LinkedIn
  
  ](https://www.linkedin.com/company/bitovi/)
- [![GitHub](https://www.bitovi.com/hubfs/GithubLogo.svg)
  
  GitHub
  
  ](https://github.com/bitovi/)

![Eggbot](https://www.bitovi.com/hubfs/build_assets/bitovi-limbo-cms-react/338/js_client_assets/assets/eggbot-LTGhdSGL.png)

Name *

Work Email *

Phone

What's your project?

Send

### Contact Us

(312) 620-0386contact@bitovi.com

[ Backend ](https://www.bitovi.com/blog/topic/backend) |  April 14, 2023

# Day.js: A Convenient Alternative to Moment.js for Node.js Consulting

 Say goodbye to Moment.js and say hello to Day.js. Learn why we migrated to this lightweight and syntactically similar alternative for Node.js consulting.

![Nicole Greene](https://www.bitovi.com/hubfs/People/nicole_greene.jpg)

 Nicole Greene

Share:

[![Twitter](https://www.bitovi.com/hubfs/limbo-generated/_astro/twitter-white.os3xLc3C_Z2nW4or.svg) ](https://twitter.com/intent/tweet?text=) [![Reddit](https://www.bitovi.com/hubfs/limbo-generated/imgs/icons/reddit.png) ](http://reddit.com/submit?url=)

With the phasing out of the popular datetime library Moment.js, one of our [Node.js consulting](https://www.bitovi.com/services/backend/nodejs-consulting) clients wanted to prioritize finding a replacement. We ultimately chose to migrate to [Day.js](https://day.js.org/), a minimalist JavaScript library. Among the alternatives, Day.js offered many advantages, chief among them being that it is lightweight and the most syntactically close to Moment.js.

## Moving Away from Moment.js

A few years ago, Moment.js updated its docs with a [Project Status](https://momentjs.com/docs/), which more or less discourages the use of the package going forward. Moment.js offers a handful of alternatives, and our team considered a few of those.

The team decided we wanted to investigate the pros and cons of three Moment.js alternatives—Luxon, date-fns, and Day.js. The spike involved comparing package sizes, skimming documentation, and estimating the cost-benefit analysis of each.

Here’s a visual overview of an analysis of the package sizes and download speed:

![moment.js-alternatives-graph](https://www.bitovi.com/hs-fs/hubfs/moment.js-alternatives-graph.png?width=694&height=546&name=moment.js-alternatives-graph.png)

## Why We Chose Day.js

Day.js started to look really appealing, given these results. We began to look into its features, usage, and advantages and found the following:

### Syntactically Similar to Moment.js

Since Day.js and Moment have similar syntax, refactoring existing code was likely to be less painful than if we chose an alternative. Many of the operations are a one-to-one replacement from Moment.js to Day.js. Take the following code snippets, which use the `format()` method to transform either a Moment.js or Day.js object into a readable string:

Moment.js:

`moment().format("MM-DD-YYYY HH:mm:ss a")`

Day.js:

`dayjs().format("MM-DD-YYYY HH:mm:ss a")`

Parsing methods like `startof()` and `endof()` are also identical in both libraries, as are the manipulation methods `.add()` and .`subtract()`.

### Tree-shaking via Plugins

One of the significant differences between Moment.js and Day.js is that the latter requires you to import and extend plugins to utilize certain features. This is a key reason why Day.js is so lightweight. A project will only bundle the plugins that are used.

### Support for Internationalization

Day.js offers internationalization (i18n) support as well via the `localeData` plugin. This evolving plugin provides useful features such as the ability to list out translated date/time strings like months in a specified location’s language:

```
const dayjs = require("dayjs");
require("dayjs/locale/es-mx")
const localeData = require("dayjs/plugin/localeData")
dayjs.extend(localeData)

const instance = dayjs().locale("es-mx")
const months = instance.localeData().months()
console.log("months: ", months)

//  months:  [
//   'enero',      'febrero',
//   'marzo',      'abril',
//   'mayo',       'junio',
//   'julio',      'agosto',
//   'septiembre', 'octubre',
//   'noviembre',  'diciembre'
//  ]
```

### Timezone Plugin

Finally, one of the reasons our team decided to use a datetime library in the first place was due to some necessary manipulation of timezones in the server of our application. Imagine a database that stores all datetimes in UTC time but an interface that displays said datetime in the user’s timezone. To handle something like that in Moment.js, we had to install an additional library called moment-timezone. Day.js includes timezone manipulation support as-is.

Day.js will parse time in local time by default. So for a machine set to US/Pacific time, all Day.js objects will display in the Pacific timezone. The `utc` plugin offers a way to convert these objects to Coordinated Universal Time, which in our case, was how we wanted to store them in the database. Here’s an example from a machine in US/Pacific time:

```
const dayjs = require("dayjs");
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)

const pacificTimestamp = dayjs(new Date("January 1, 2023")).format("MM-DD-YY hh:mm a")
console.log(pacificTimestamp)
// prints "01-01-23 00:00 am"

const utcTimestamp = dayjs(pacificTimestamp).utc().format("MM-DD-YY hh:mm a")
console.log(utcTimestamp)
// prints "01-01-23 08:00 am"
```

The `timezone` plugin and `.tz()` method offers further support for displaying dates in different locales. Take the following, which displays a date in the computer’s timezone (Pacific) and converts it to Eastern time.

```
const dayjs = require("dayjs")
const timezone = require("dayjs/plugin/timezone")
dayjs.extend(timezone)
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)

const pst = dayjs().format("MM-DD-YYYY h:mm a")
console.log(pst)
// 01-01-2023 12:00 am

const est = dayjs.tz(dayjs(pst), "America/Toronto").format("MM-DD-YYYY h:mm a")
console.log(est)
// 01-01-2023 3:00 am
```

## Conclusion

In summary, Day.js is a solid choice for projects needing the convenience and support of a datetime library, particularly if looking to replace Moment.js. It offers a lot of the same features in a smaller package, and its syntax will be familiar to teams already using Moment.js.

### Do you think Day.js is a good alternative to Moment?

We’d love to hear your thoughts! Join our [Community Discord](https://discord.gg/J7ejFsZnJ4) to learn about the latest in [Node.js Consulting](https://www.bitovi.com/services/backend/nodejs-consulting), network with our community, and ask questions! 👋

[![Join our Discord](https://no-cache.hubspot.com/cta/default/2171535/bf938bba-b067-4eaf-991d-c9a41bfefaad.png)](https://cta-redirect.hubspot.com/cta/redirect/2171535/bf938bba-b067-4eaf-991d-c9a41bfefaad)

 

 

 

[![Tag for node.js](https://www.bitovi.com/hubfs/limbo/icons/tag.svg) node.js ](https://www.bitovi.com/blog/topic/node-js)

 Previous Post

![5 Essential Tips to Improve Angular App Performance](https://www.bitovi.com/hs-fs/hubfs/5%20Essential%20Tips%20to%20Improve%20Angular%20App%20Performance-2.png?height=117&name=5%20Essential%20Tips%20to%20Improve%20Angular%20App%20Performance-2.png) [ 5 Essential Tips to Improve Angular App Performance ](https://www.bitovi.com/blog/5-essential-tips-to-improve-angular-app-performance)

  

 Next Post

![React Native: 7 Common Questions Answered by a React Consulting Expert](https://www.bitovi.com/hs-fs/hubfs/React%20Native-%207%20Common%20Questions%20Answered%20by%20a%20React%20Consulting%20Expert-1.png?height=117&name=React%20Native-%207%20Common%20Questions%20Answered%20by%20a%20React%20Consulting%20Expert-1.png) [ React Native: 7 Common Questions Answered by a React Consulting Expert ](https://www.bitovi.com/blog/react-native-7-common-questions-answered-by-a-react-consulting-expert)

```json
{
  "@context" : "http://schema.org",
  "@type" : "Organization",
  "address" : {
    "@type" : "PostalAddress",
    "addressCountry" : "United States",
    "addressLocality" : "Libertyville",
    "addressRegion" : "IL",
    "postalCode" : "60048",
    "streetAddress" : "1134 Pine Tree Lane "
  },
  "alternateName" : "Bitovi",
  "areaServed" : {
    "@type" : "GeoCircle",
    "geoMidpoint" : {
      "@type" : "GeoCoordinates",
      "latitude" : "41.8781",
      "longitude" : "87.6298"
    },
    "geoRadius" : "5000 km"
  },
  "description" : "Bitovi is a UX, UI design and front-end JavaScript development consulting company",
  "email" : "contact@bitovi.com",
  "image" : "https://www.bitovi.com/hubfs/bitovi-logo-x2.png",
  "logo" : "https://www.bitovi.com/hubfs/bitovi-logo-23-1.svg",
  "mainEntityOfPage" : {
    "@id" : "https://www.bitovi.com/blog/day.js-a-convenient-alternative-to-moment.js-for-node.js-consulting",
    "@type" : "WebPage",
    "description" : "Say goodbye to Moment.js and say hello to Day.js. Learn why we migrated to this lightweight and syntactically similar alternative for Node.js consulting."
  },
  "naics" : "541511",
  "name" : "Bitovi Web App Consulting",
  "sameAs" : [ "https://www.facebook.com/BitoviLLC/", "https://twitter.com/bitovi", "https://www.linkedin.com/company/bitovi" ],
  "telephone" : "312-620-0386",
  "url" : "http://bitovi.com"
}
```

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Nicole Greene"
  },
  "dateModified" : "October 3, 2023, 7:55:52 PM",
  "datePublished" : "2023-04-14 14:00:00",
  "description" : "Say goodbye to Moment.js and say hello to Day.js. Learn why we migrated to this lightweight and syntactically similar alternative for Node.js consulting.",
  "headline" : "Day.js: A Convenient Alternative to Moment.js for Node.js Consulting",
  "image" : {
    "@type" : "ImageObject",
    "url" : "https://www.bitovi.com/hubfs/Day.js-%20A%20Convenient%20Alternative%20to%20Moment.js%20for%20Node.js%20Consulting.png"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://www.bitovi.com/hubfs/bitovi-logo-23-1.svg"
    },
    "name" : "Bitovi"
  }
}
```