Skip to content
Advertisement

Deprecation warning in Moment.js – Not in a recognized ISO format

I’m getting a warning that a value provided to moment is not in a recognized ISO format. I changed my variable today with the moment function and still it doesn’t work.

Here’s the warning error:

Deprecation warning: value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. Arguments: [0] _isAMomentObject: true, _isUTC: true, _useUTC: true, _l: undefined, _i: 2016-9-26 19:30, _f: undefined, _strict: undefined, _locale: [object Object]

JavaScript

Advertisement

Answer

Check out all their awesome documentation!

Here is where they discuss the Warning Message.

String + Format

Warning: Browser support for parsing strings is inconsistent. Because there is no specification on which formats should be supported, what works in some browsers will not work in other browsers.

For consistent results parsing anything other than ISO 8601 strings, you should use String + Format.

JavaScript

String + Formats (multiple formats)

If you have more than one format, check out their String + Formats (with an ‘s’).

If you don’t know the exact format of an input string, but know it could be one of many, you can use an array of formats.

JavaScript

Please check out the documentation for anything more specific.

Timezone

Check out Parsing in Zone, the equivalent documentation for timezones.

The moment.tz constructor takes all the same arguments as the moment constructor, but uses the last argument as a time zone identifier.

JavaScript

EDIT

JavaScript
Advertisement