A common task, and every developer must face, is related to the formatting of dates with JavaScript, either by converting formats or performing calculations between two or more dates.
JavaScript has many functions for manipulating dates, however make such calculations is not always as simple. To facilitate working with dates is that there Moment.js, a small JavaScript library that provides us with some simple mechanisms to operate with dates.
Formatting dates with JavaScript
moment().format(‘dddd, MMMM Do YYYY, h:mm:ss a’);
moment().format(‘dddd [on the] wo [week of the year]‘);
moment().format(“MMM Do ‘YY”);
moment().format(); // defaults to ISO-8601
Moment.js not only serves us to convert formats of dates and times, it is also extremely useful for performing arithmetic and calculations between two different dates.

JavaScript dates
Calculate time elapsed since a date
moment(“2011-10-31″, “YYYY-MM-DD”).fromNow();
One detail that is contemplated in Moments.js and not so with other similar alternatives, is the representation of dates by country. That detail is perfectly studied in this small library, with it we can get the dates in several different languages and with just a few lines of code.
English : Wednesday, April 18 2012 12:42 PM
Catalan : Dimecres 18 Abril 2012 12:42
Danish : Onsdag 18. April, 2012 12:42 PM
German : Mittwoch, 18. April 2012 12:42 Uhr
Spanish : Miércoles 18 Abril 2012 12:42
Basque : asteazkena, 2012ko apirilaren 18a 12:42
French : mercredi 18 avril 2012 12:42
Galician : Mércores 18 Abril 2012 12:42
Italian : Mercoledi, 18 Aprile 2012 12:42
Korean : 2012년 4월 18일 수요일 오후 12시 42분
Norwegian : onsdag 18 april 2012 12:42
Dutch : woensdag 18 april 2012 12:42
Polish : środa, 18 kwiecień 2012 12:42
Portuguese : Quarta-feira, 18 de Abril de 2012 12:42
Russian : среда, 18 апрель 2012 12:42
Swedish : onsdag 18 april 2012 12:42
Turkish : Çarşamba, 18 Nisan 2012 12:42
Chinese : 星期三, 18 四月 2012 12:42 下午
Moments.js is very light, just 3.7kb in its simplified version, compressed with gzip. The author provides downloading the development version, this is particularly useful for those who want to further reduce the library size by eliminating all unnecessary code, for example, we remove everything related to the language that we will not use.