In code below, I don't want the string not_a_date
to be whitelisted as a proper date, but rather as NaN
or invalid date
. but Date.parse
returns a proper epoch value.
not_a_date = 'https://www.example.com/2021/03/03'
Date.parse(not_a_date)
// Expected: NaN
// Result: 1614709800000
- Not looking for a exact format match, but a fuzzy match that still works the same as
Date.parse
for other cases such as2020.01.01
,01/10/2020
- Another function that achieves this also works for me.