Moment.js 2.8.4

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

Download

moment.js moment.min.js 11.3k moment+locales.js moment+locales.min.js 40.7k

Install

bower install moment --save # bower
npm install moment --save   # npm
Install-Package Moment.js   # NuGet

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().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 (Morocco)
Arabic (Saudi Arabia)
Armenian
Azerbaijani
Bahasa Indonesia
Bahasa Malayu
Basque
Belarusian
Bengali
Bosnian
Breton
Bulgarian
Burmese
Catalan
Chinese
Chinese (Traditional)
Chuvash
Croatian
Czech
Danish
Dutch
English
English (Australia)
English (Canada)
English (England)
Esperanto
Estonian
Farose
Finnish
French
French (Canada)
Galician
Georgian
German
German (Austria)
Greek
Hebrew
Hindi
Hungarian
Icelandic
Italian
Japanese
Khmer (Cambodia)
Korean
Latvian
Lithuanian
Luxembourgish
Macedonian
Malayalam
Marathi
Nepalese
Norwegian
Norwegian Nynorsk
Persian
Polish
Portuguese
Portuguese (Brazil)
Romanian
Russian
Serbian
Serbian Cyrillic
Slovak
Slovenian
Spanish
Swedish
Tagalog (Filipino)
Tamaziɣt
Tamaziɣt Latin
Tamil
Thai
Tibetan
Turkish
Ukrainian
Uzbek
Vietnamese
Welsh