moment.js not rely on any third-party libraries, support string, Date, time stamp, and an array of other formats, can be like PHP's date () function, the date and time formatting, calculation of relative time, access to a specific date and time after time, etc. and so on, this article has the following examples.
Formatting Date
Current time:
moment().format('YYYY-MM-DD HH:mm:ss'); //2014-09-24 23:36:09
The day of the week
moment().format('d'); //3
Convert Unix timestamp current time
moment().format('X');
Relative Time
20120901 relative to the current date is two years ago
moment("20120901", "YYYYMMDD").fromNow(); //2 years ago
7 days after the date
moment().add('days',7).format('YYYY-MM-DD'); //2014-10-01
9 hours after now
moment().add('hours',9).format('HH:mm:ss');
moment.js provides a wealth of documentation, you can use it to create complex projects, such as the date and time the application calendar.
For more information about moment.js presentation, please visit the project's official website: http: //momentjs.com/