new moment with format 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 format date
moment().subtract(10, 'days').calendar(); // 03/16/2021
moment().subtract(6, 'days').calendar(); // Last Saturday at 12:25 PM
moment().subtract(3, 'days').calendar(); // Last Tuesday at 12:25 PM
moment().subtract(1, 'days').calendar(); // Yesterday at 12:25 PM
moment().calendar(); // Today at 12:25 PM
moment().add(1, 'days').calendar(); // Tomorrow at 12:25 PM
moment().add(3, 'days').calendar(); // Monday at 12:25 PM
moment().add(10, 'days').calendar(); // 04/05/2021