Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Date.parse() false positives

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 as 2020.01.01, 01/10/2020
  • Another function that achieves this also works for me.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Date.parse is still largely dependant on the browser you're using; your code DOES return NaN in Firefox v94 for example. You'll likely have to write your own parsing function before passing it to Date.parse().

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!