date to moment js code example
Example 1: moment format
moment().format('MMMM Do YYYY, h:mm:ss a'); // September 30th 2020, 2:48:17 pm
moment().format('dddd'); // Wednesday
moment().format("MMM Do YY"); // Sep 30th 20
moment().format('YYYY [escaped] YYYY'); // 2020 escaped 2020
moment().format(); // 2020-09-30T14:48:17+02:00
Example 2: moment to date
moment().toDate();
Example 3: moment js from now
moment(date).fromNow();
Example 4: moment to javascript date
let now = moment()
let now = now.toDate()
Example 5: moment js print date
moment(testDate).format('MM/DD/YYYY');
Example 6: moment format heure
var time = "15:30:00";
var formatted = moment(time, "HH:mm:ss").format("LT");
console.log(formatted);
//it will return 3:30 PM