标签云

微信群

扫码加入我们

WeChat QR Code

This question already has an answer here:Detecting an “invalid date” Date instance in JavaScript39 answersI raised strange issue:var d = new Date("2016--01---01");Would create object without any errors. Actually, first question is - why?But then i need to get string from this object - i am trying tod.toString(); // 'Invalid Date'd.getTime();// NaNd.toJSON(); // nullWhat it is possible ways to get string or check that it is incorrect?


do you want check whether the provided string is vaild date or not ?

2019年06月26日01分23秒

Do you want to check that the string is valid before creating the Date(), or that the Date() is invalid afterwards?

2019年06月26日01分23秒

i need to get error on creating or actual wrong date from Date object

2019年06月25日01分23秒