我想将日期转换为时间戳,我的输入是26-02-2012。我用了
26-02-2012
new Date(myDate).getTime();
上面写着NaN ..有人能告诉你如何转换吗?
var myDate = “26-02-2012”; myDate = myDate.split(“-“); var newDate = myDate[1]+”,”+myDate[0]+”,”+myDate[2]; console.log(new Date(newDate).getTime());
更新:
var myDate = "26-02-2012"; myDate = myDate.split("-"); var newDate = myDate[1]+"/"+myDate[0]+"/"+myDate[2]; console.log(new Date(newDate).getTime());