🛠️
Utility20M+/wkMIT

moment

Moment.js is a JavaScript date library for parsing, validating, manipulating, and formatting dates that was the standard date handling library for JavaScript ap

Installation

npm
npm install moment
yarn
yarn add moment
pnpm
pnpm add moment

Import

ESM
import moment from 'moment';

Quick Example

usage
import moment from 'moment';

const now = moment();
console.log(now.format('MMMM Do YYYY, h:mm:ss a'));
console.log(moment('2024-06-15').fromNow());
console.log(now.add(7, 'days').calendar());

About moment

Moment.js is a JavaScript date library for parsing, validating, manipulating, and formatting dates that was the standard date handling library for JavaScript applications for nearly a decade. Moment provides an intuitive chaining API: moment().add(7, 'days').format('MMMM Do YYYY'). The library handles parsing from multiple formats, timezone conversions (via moment-timezone), relative time display ('3 hours ago'), calendar formatting, locale-aware date display for over 100 locales, duration calculations, and comprehensive comparison utilities. Moment.js is now in maintenance mode — the maintainers recommend using modern alternatives like date-fns, Day.js, or Luxon for new projects. The primary concerns with Moment.js are its large bundle size (around 67KB minified plus locale data), its mutable API design which can lead to subtle bugs when date objects are shared, and its monolithic architecture that prevents tree shaking. Despite being in maintenance mode, Moment.js remains one of the most downloaded npm packages due to its extensive use in existing codebases and as a dependency of popular libraries like react-datepicker and FullCalendar.

Quick Facts

Packagemoment
CategoryUtility
Weekly Downloads20M+
LicenseMIT
Installnpm install moment

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.