Skip to content

Consider bringing back old parse #2231

Answered by kossnocorp
nfantone asked this question in Q&A
Discussion options

You must be logged in to vote

@nfantone the things are much more straightforward than discussed in the thread. Sorry for the confusion.

Simply use new Date() or Date.parse() to parse free-form strings. This is how old parse worked and unless you know why you need parse/parseISO/parseJSON/etc, you should not use any of that.

new Date('2020/05/05')
//=> Tue May 05 2020 00:00:00 GMT+0800 (Singapore Standard Time)

Date.parse('2020/05/05')
//=> 1588608000000

As @Qvatra noted, this is not consistent across browsers (but will work for you example) and v1 didn't fix that, and this is why we removed it in the first place. It's impossible to write a universal string parser and this inconsistency is the evidence of that.

If you…

Replies: 15 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@nfantone
Comment options

@green-arrow
Comment options

@nfantone
Comment options

@joshuat
Comment options

@JoshuaWi-Playroll
Comment options

Answer selected by kossnocorp
Comment options

You must be logged in to vote
1 reply
@nonbob
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants
Converted from issue

This discussion was converted from issue #750 on February 22, 2021 14:12.