我有一个我无法解决的简单问题。下面的代码在 chrome 中运行良好,但在其他浏览器中出现 NaN 错误......
function chkdate()
{
var todayDate=new Date();
var date=todayDate.getDate();
if( date<10)
{
date= "0"+date;
}
var month=todayDate.getMonth()+1;
if( month<10)
{
month= "0"+month;
}
var year=todayDate.getFullYear();
var hours=todayDate.getHours();
if( hours<10)
{
hours= "0"+hours;
}
var curdate = year+"-"+month+"-"+date+" "+hours+":00:00" ;
alert(curdate);
var curtime= new Date(curdate).getTime();
alert("current timestamp = "+ curtime) ; // <---- **This gives NaN error .**