Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12231

new Date() validation of string with number

$
0
0

When inputing string with number the new Date() is missbehaving, is there another way how to achieve this without regex?

let string = 'some string 1';let invalid = new Date(string);

it is still parsing as a Date value

Mon Jan 01 2001 00:00:00 GMT+0000 (Greenwich Mean Time)

I'm expecting it as an invalid date


Viewing all articles
Browse latest Browse all 12231

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>