Tutorial by Examples

Moment is a javascript library that was designed to make working with dates and times less time-consuming and more intuitive. You can easily start using this library by installing it in you web-app by using one of the following guides. Browser You can either download the JS file from the official...
The way Moment uses dates and times is by wrapping the existing Date() object in a moment() object and specifying useful and intuitive methods on this object. Format Dates moment().format('MMMM Do YYYY, h:mm:ss a'); // August 4th 2016, 10:41:45 am moment().format('dddd'); // Th...
To turn a Javascript Date object into a moment (moment object) just call moment and pass the Date as a argument moment(new Date()); // Moment {_isAMomentObject: true, _i: Sun Jul 31 2016 11:08:02 GMT+0300 (Jerusalem Daylight Time), _isUTC: false, _pf: Object, _locale: Locale…} To turn the momen...
If you have a moment object you can use add and substract to manipulate it or set any property of the time directly moment("2016-01-01").add(1, 'year').format('YYYY-MM-DD') // -> "2017-01-01" Or use .day(), .month(), .year(), .seconds(), .milliseconds() to set those val...
You can use moment to parse date strings. By default moment tries to parse the date as an ISO-8601 string and if that does not work falls back to the browsers new Date(). Since the way that browsers construct dates varies it is best to try not to fall back to this. moment('2016-02-04').format('YYY...

Page 1 of 1