Considering using Moment in your project?
There may be better modern alternatives.
For more details and recommendations,
please see Project Status in the docs.

Moment.js 2.30.1

Parse, validate, manipulate, and display dates and times in JavaScript.

Download

moment.js moment.min.js 18.4k moment-with-locales.js moment-with-locales.min.js 74.6k

Install

npm install moment --save   # npm
yarn add moment             # Yarn
Install-Package Moment.js   # NuGet
spm install moment --save   # spm
meteor add momentjs:moment  # meteor
bower install moment --save # bower (deprecated)

Format Dates

moment().format('MMMM Do YYYY, h:mm:ss a');
moment().format('dddd');
moment().format("MMM Do YY");
moment().format('YYYY [escaped] YYYY');
moment().format();

Relative Time

moment("20111031", "YYYYMMDD").fromNow();
moment("20120620", "YYYYMMDD").fromNow();
moment().startOf('day').fromNow();
moment().endOf('day').fromNow();
moment().startOf('hour').fromNow();

Calendar Time

moment().subtract(10, 'days').calendar();
moment().subtract(6, 'days').calendar();
moment().subtract(3, 'days').calendar();
moment().subtract(1, 'days').calendar();
moment().calendar();
moment().add(1, 'days').calendar();
moment().add(3, 'days').calendar();
moment().add(10, 'days').calendar();

Multiple Locale Support

moment.locale();
moment().format('LT');
moment().format('LTS');
moment().format('L');
moment().format('l');
moment().format('LL');
moment().format('ll');
moment().format('LLL');
moment().format('lll');
moment().format('LLLL');
moment().format('llll');
Afrikaans
Albanian
Arabic
Arabic (Algeria)
Arabic (Kuwait)
Arabic (Libya)
Arabic (Morocco)
Arabic (Palestine)
Arabic (Saudi Arabia)
Arabic (Tunisia)
Armenian
Azerbaijani
Bambara
Basque
Belarusian
Bengali
Bengali (Bangladesh)
Bosnian
Breton
Bulgarian
Burmese
Cambodian
Catalan
Central Atlas Tamazight
Central Atlas Tamazight Latin
Chinese (China)
Chinese (Hong Kong)
Chinese (Macau)
Chinese (Taiwan)
Chuvash
Croatian
Czech
Danish
Dutch
Dutch (Belgium)
English (Australia)
English (Canada)
English (India)
English (Ireland)
English (Israel)
English (New Zealand)
English (Singapore)
English (United Kingdom)
English (United States)
Esperanto
Estonian
Faroese
Filipino
Finnish
French
French (Canada)
French (Switzerland)
Frisian
Galician
Georgian
German
German (Austria)
German (Switzerland)
Greek
Gujarati
Hebrew
Hindi
Hungarian
Icelandic
Indonesian
Irish or Irish Gaelic
Italian
Italian (Switzerland)
Japanese
Javanese
Kannada
Kazakh
Klingon
Konkani Devanagari script
Konkani Latin script
Korean
Kurdish
Kyrgyz
Lao
Latvian
Lithuanian
Luxembourgish
Macedonian
Malay
Malayalam
Maldivian
Maltese (Malta)
Maori
Marathi
Mongolian
Montenegrin
Nepalese
Northern Kurdish
Northern Sami
Norwegian Bokmål
Nynorsk
Occitan, lengadocian dialecte
Persian
Polish
Portuguese
Portuguese (Brazil)
Pseudo
Punjabi (India)
Romanian
Russian
Scottish Gaelic
Serbian
Serbian Cyrillic
Sindhi
Sinhalese
Slovak
Slovenian
Spanish
Spanish (Dominican Republic)
Spanish (Mexico)
Spanish (United States)
Swahili
Swedish
Tagalog (Philippines)
Tajik
Talossan
Tamil
Telugu
Tetun Dili (East Timor)
Thai
Tibetan
Turkish
Turkmen
Ukrainian
Urdu
Uyghur (China)
Uzbek
Uzbek Latin
Vietnamese
Welsh
Yoruba Nigeria
siSwati