moment today time format code example

Example 1: 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 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