Start of Time1.7.0+

  1. moment().startOf(String);

Mutates the original moment by setting it to the start of a unit of time.

  1. moment().startOf('year'); // set to January 1st, 12:00 am this year
  2. moment().startOf('month'); // set to the first of this month, 12:00 am
  3. moment().startOf('quarter'); // set to the beginning of the current quarter, 1st day of months, 12:00 am
  4. moment().startOf('week'); // set to the first day of this week, 12:00 am
  5. moment().startOf('isoWeek'); // set to the first day of this week according to ISO 8601, 12:00 am
  6. moment().startOf('day'); // set to 12:00 am today
  7. moment().startOf('date'); // set to 12:00 am today
  8. moment().startOf('hour'); // set to now, but with 0 mins, 0 secs, and 0 ms
  9. moment().startOf('minute'); // set to now, but with 0 seconds and 0 milliseconds
  10. moment().startOf('second'); // same as moment().milliseconds(0);

These shortcuts are essentially the same as the following.

  1. moment().startOf('year');
  2. moment().month(0).date(1).hours(0).minutes(0).seconds(0).milliseconds(0);
  1. moment().startOf('hour');
  2. moment().minutes(0).seconds(0).milliseconds(0)

As of version 2.0.0, moment#startOf('day') replaced moment#sod.

Note: moment#startOf('week') was added in version 2.0.0.

As of version 2.1.0, moment#startOf('week') uses the locale aware week start day.

Note: moment#startOf('isoWeek') was added in version 2.2.0.

Note: moment#startOf('date') was added as an alias for day in 2.13.0