Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 802 Bytes

02-invalid.md

File metadata and controls

25 lines (19 loc) · 802 Bytes
title version signature
Invalid
2.3.0
moment.invalid(Object);

You can create your own invalid Moment objects, which is useful in making your own parser.

var m = moment.invalid();
m.isValid();                      // false
m.format();                       // 'Invalid date'
m.parsingFlags().userInvalidated; // true

invalid also accepts an object which specifies which parsing flags to set. This will not set the userInvalidated parsing flag unless it's one of the properties specified.

var m = moment.invalid({invalidMonth: 'Actober'});
m.parsingFlags().invalidMonth; // 'Actober'

You need not specify parsing flags recognized by Moment; the Moment will be invalid nonetheless, and the parsing flags will be returned by parsingFlags().