目前,我使用:检测,如果字符串可以转换成日期
var d = new Date("March 7 2012");
document.write(d.getMonth() + 1);
如果日期字符串是一个很奇怪的像No Date
即:
var d = new Date("No Date"); // anything which isn't recognisable as a date
document.write(d.getMonth() + 1);
这里的输出我得到是NaN
如果发生类似情况,我该如何显示更好的信息
可能重复(http://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript) – 2012-03-07 16:40:26