Moment.js 2.18.1

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

Download

moment.js moment.min.js 16.6k moment-with-locales.js moment-with-locales.min.js 64.2k

Install

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

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 (Lybia)
Arabic (Morocco)
Arabic (Saudi Arabia)
Arabic (Tunisia)
Armenian
Azerbaijani
Basque
Belarusian
Bengali
Bosnian
Breton
Bulgarian
Burmese
Cambodian
Catalan
Central Atlas Tamazight
Central Atlas Tamazight Latin
Chinese (China)
Chinese (Hong Kong)
Chinese (Taiwan)
Chuvash
Croatian
Czech
Danish
Dutch
Dutch (Belgium)
English (Australia)
English (Canada)
English (Ireland)
English (New Zealand)
English (United Kingdom)
English (United States)
Esperanto
Estonian
Faroese
Finnish
French
French (Canada)
French (Switzerland)
Frisian
Galician
Georgian
German
German (Austria)
German (Switzerland)
Greek
Hebrew
Hindi
Hungarian
Icelandic
Indonesian
Italian
Japanese
Javanese
Kannada
Kazakh
Klingon
Konkani Latin script
Korean
Kyrgyz
Lao
Latvian
Lithuanian
Luxembourgish
Macedonian
Malay
Malay
Malayalam
Maldivian
Maori
Marathi
Montenegrin
Nepalese
Northern Sami
Norwegian Bokmål
Nynorsk
Persian
Polish
Portuguese
Portuguese (Brazil)
Pseudo
Punjabi (India)
Romanian
Russian
Scottish Gaelic
Serbian
Serbian Cyrillic
Sindhi
Sinhalese
Slovak
Slovenian
Spanish
Spanish (Dominican Republic)
Swahili
Swedish
Tagalog (Philippines)
Talossan
Tamil
Telugu
Tetun Dili (East Timor)
Thai
Tibetan
Turkish
Ukrainian
Urdu
Uzbek
Uzbek Latin
Vietnamese
Welsh
Yoruba Nigeria
siSwati