Moment.js gives an invalid date in Firefox.

I have a requirement for converting date dates to moment.js. But this gives me a great result in Chrome and Firefox.

In Google Chrome, it gives the correct result, but in Mozilla firefox gives an "Invalid date".

Google chrome

moment('2016-Jan-02 02:00 AM').format()
Output: "2016-01-02T02:00:00+05:30"

Mozilla firefox

moment('2016-Jan-02 02:00 AM').format()
"Invalid date"

Your help is greatly appreciated.

+5
source share
2 answers

It is recommended that you avoid using parsing in accordance with your custom format. As the documentation says :

: . , , , , .

, ISO 8601, String + Format.

:

moment('2016-Jan-02 02:00 AM', 'YYYY-MMM-DD HH:mm A')
+10

2016-Jan-02. Date, . , .

moment("2016-Jan-02", "DD-MMM-YYYY")

, , , :

moment("2016-Jan-02", "DD-MMM-YYYY").format("DD-MM-YYYY")

02-01-2016 .

0

Source: https://habr.com/ru/post/1622303/


All Articles