Q:

moment.js 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
7
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"
9
moment().format();                                // "2014-09-08T08:02:17-05:00" (ISO 8601, no fractional seconds)
moment().format("dddd, MMMM Do YYYY, h:mm:ss a"); // "Sunday, February 14th 2010, 3:25:50 pm"
moment().format("ddd, hA");                       // "Sun, 3PM"
moment('gibberish').format('YYYY MM DD');         // "Invalid date"
1
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
0
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
0

New to Communities?

Join the community