我想得到的是: function TimeCount(mTime){ var time1=new Date(); var time2=new Date(); time2=time1.getTime() - mTime.getTime(); } 其中time2是计算后的差,mTime的格式是2002-07-25 12:23:10;
<script> function TimeCount(mTime){ var time2=new Date(mTime.replace("-","/")); var time1=new Date(); return (time1.getTime()-time2.getTime())/1000/60; } alert(TimeCount("2002-07-19 12:23:12")) alert(TimeCount("2002-07-25 17:23:10")) </script>
函数我已经写出来了。 function MyTime(mTime) { var Time2=new Date(); var vStr; vDate=mTime.split(" "); vStr=vDate[1].split("-"); vYear=vStr[0]; vMonth=vStr[1]; vDay=vStr[2]; vStr=vDate[2].split(":"); vHours=vStr[0]; vMinutes=vStr[1]; vSeconds=vStr[2]; Time1 = new Date(Date.UTC(vYear, vMonth - 1, vDay, vHours-8, vMinutes, vSeconds)); vIn=(Time2.getTime()-Time1.getTime())/1000; alert(Time2.toLocaleString()); }
function TimeCount(mTime){
var time1=new Date();
var time2=new Date();
time2=time1.getTime() - mTime.getTime();
}
其中time2是计算后的差,mTime的格式是2002-07-25 12:23:10;
function TimeCount(mTime){
var time2=new Date(mTime.replace("-","/"));
var time1=new Date();
return (time1.getTime()-time2.getTime())/1000/60;
}
alert(TimeCount("2002-07-19 12:23:12"))
alert(TimeCount("2002-07-25 17:23:10"))
</script>
function MyTime(mTime) {
var Time2=new Date();
var vStr;
vDate=mTime.split(" ");
vStr=vDate[1].split("-");
vYear=vStr[0];
vMonth=vStr[1];
vDay=vStr[2];
vStr=vDate[2].split(":");
vHours=vStr[0];
vMinutes=vStr[1];
vSeconds=vStr[2];
Time1 = new Date(Date.UTC(vYear, vMonth - 1, vDay, vHours-8, vMinutes, vSeconds)); vIn=(Time2.getTime()-Time1.getTime())/1000;
alert(Time2.toLocaleString());
}