DEV Community

Discussion on: Oh Javascript... 🙄

Collapse
 
variadicism profile image
Connor Davey

At my company, we use moment.js. My colleagues recommend that.

Thread Thread
 
squgeim profile image
Shreya Dahal

Using moment does not solve this issue. Initializing date with a string that is not strictly ISO 8601 is inconsistent in the specification itself and depends on the browser.

On Safari:

> new Date('2018-3-14')
â‹– Invalid Date
> moment('2018-3-14')
â‹– Invalid Date

This works on Chrome, though. :D

More about the moment issue here: github.com/moment/moment/issues/1407

I have a more thorough write-up on this with a lot more caveats here: blog.lftechnology.com/date-ing-jav...

Thread Thread
 
kspeakman profile image
Kasey Speakman

Thanks for the link. That is a great article on many of the JS Date caveats.