moment.js time format code example
Example 1: moment format
moment().format('MMMM Do YYYY, h:mm:ss a');
moment().format('dddd');
moment().format("MMM Do YY");
moment().format('YYYY [escaped] YYYY');
moment().format();
Example 2: moment js date diff
var now = "04/09/2013 15:00:00";
var then = "02/09/2013 14:20:30";
var ms = moment(now,"DD/MM/YYYY HH:mm:ss").diff(moment(then,"DD/MM/YYYY HH:mm:ss"));
var d = moment.duration(ms);
var s = d.format("hh:mm:ss");
Example 3: moment add seconds
var travelTime = moment().add(642, 'seconds').format('hh:mm A');
var travelTime = moment().add(11, 'minutes').format('hh:mm A');
var travelTime = moment().add(2, 'hours').format('hh:mm A');
Example 4: moment format date
moment().format();
moment().format("dddd, MMMM Do YYYY, h:mm:ss a");
moment().format("ddd, hA");
Example 5: date format in moment js
moment().format('MMMM Do YYYY');
moment().format('dddd');
moment().format("MMM Do YY");
moment().format('YYYY [escaped] YYYY');
moment().format();