moment js milliseconds to date code example

Example 1: moment check valid date

var date = moment("2016-10-19");
var check = date.isValid();
console.log(check);

Example 2: moment to date

moment().toDate();

Example 3: moment.js format

moment().format('MMMM Do YYYY, h:mm:ss a'); // December 4th 2020, 1:04:29 pm
moment().format('dddd');                    // Friday
moment().format("MMM Do YY");               // Dec 4th 20
moment().format('YYYY [escaped] YYYY');     // 2020 escaped 2020
moment().format();                          // 2020-12-04T13:04:29-05:00

Example 4: how to convert millisecond to second to date momentjs

var day = moment(1318781876406);