moment date to yyyy-mm-dd code example
Example 1: moment format date dd/mm/yyyy
moment(new Date()).format("DD/MM/YYYY")
Example 2: 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 3: moment yyyy-MM-ddTHH:mm
moment().format("YYYY-MM-DD[T]HH:mm:ss");
Example 4: moment format date
moment().format(); // "2019-08-12T17:52:17-05:00" (ISO 8601, no fractional seconds)
moment().format("dddd, MMMM Do YYYY, h:mm:ss a"); // "Monday, August 12th 2019, 5:52:00 pm"
moment().format("ddd, hA"); // "Mon, 5PM"
Example 5: moment now format
var date = moment().format('MM/DD/YYYY');