Transform

  1. bower install moment-transform

moment-transform is a plugin that manipulated dates through patterns. You can use basic operations –set/add/subtract– on individual parts (hours, month, …) of a Moment instance.

  1. moment().transform('YYYY-MM-+01 00:00:00.000'); // Tonight at midnight
  2. moment().transform('14:30:00.000'); // Today, 2:30 pm
  3. moment().transform('YYYY-MM--30 00:00:00.000'); // 30 days ago

Optional parameters lets you specify custom patterns and force strict pattern usage (non-alphabetic characters are not mandatory in passed string by default).

  1. moment().transform('+01MMYYYY', 'DD/MM/YYYY', false); // Tomorrow, same time
  2. moment().transform('+01MMYYYY', 'DD/MM/YYYY', true); // Invalid date

You can see it live there while the repository is here.