how to check time is ended on using moment js code example

Example 1: format a date moment

moment(testDate).format('MM/DD/YYYY');

Example 2: moment date add

var new_date = moment(startdate, "DD-MM-YYYY").add(5, 'days');

Example 3: moment diff

var a = moment([2007, 0, 29]);
var b = moment([2007, 0, 28]);
a.diff(b, 'days') // 1

Example 4: moment.js format

moment("20111031", "YYYYMMDD").fromNow(); // 9 years ago
moment("20120620", "YYYYMMDD").fromNow(); // 8 years ago
moment().startOf('day').fromNow();        // 13 hours ago
moment().endOf('day').fromNow();          // in 11 hours
moment().startOf('hour').fromNow();       // 4 minutes ago

Tags:

Misc Example