Latest commit 27ac079 Jan 30, 2017 @A---- committed on GitHub Merge pull request #3 from fabianoroberto/master
Fix bower.json
Failed to load latest commit information.
src Correct handling of months (usual weird indexing) May 4, 2015
Gruntfile.js Adding bitwise check to jshint Apr 28, 2015
LICENSE Initial commit Apr 21, 2015
karma.conf.js Moving source file Apr 22, 2015
package.json Updating to v1.0.1 Apr 6, 2016


A plugin for Moment.js that allows date transformation from a pattern.


First, download the plugin by:

  • cloning this repository,
  • use npm or bower,
  • checking the dist/ folder.

Include it in your website/app (after moment if you don't use require).


var tomorrow = moment().transform('YYYY-MM-+01');
var midnightTonight = moment().transform('YYYY-MM-+01 00:00:00.000');
var breakfirstTimeToday = moment().transform('07:30:00');

// Optional pattern argument
tomorrow = moment().transform('+01/MM/YYYY', 'DD/MM/YYYY');
// Multiple patterns, take the first that fits
midnightTonight = moment().transform('+01/MM/YYYY 00:00:00.000', ['DD/MM/YYYY', 'DD/MM/YYYY HH:mm:ss.SSS']);

// Optional strict argument
tomorrow = moment().transform('+01MMYYYY', 'DD/MM/YYYY', false); // this works
var invalid = moment().transform('+01MMYYYY', 'DD/MM/YYYY', true); // this will return an invalid date.
invalid.isValid(); // false
breakfirstTimeToday = moment().transform('07:30:00', undefined, true); // with default patterns


transform() takes up to three arguments:

  • value: value to be checked against the pattern,
  • patterns (optional): a string or an array of strings. Check format() documentation for syntax. Default value is ['YYYY-MM-DD HH:mm:ss.SSS', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'HH:mm:ss.SSS', 'HH:mm:ss'].
  • strict (optional): non-alphabetic characters in patterns are not mandatory when not strict. Default is false.


Fork the repository and do a npm install.

You can check your code is correct by doing a grunt test.

When you're done, do a grunt build.