标签:atime turn ftime return gettime second data man int
function diffTime(time){
var oDate1 = new Date(time);//2017-02-28 12:10:00
var oDate2 = new Date();
var nTime = oDate2.getTime() - oDate1.getTime();
var hour = 0;
var minute = 0;
var second = 0;
var second = nTime / 1000;
if (second > 60) {
minute = second / 60;
second = second % 60;
}
if (minute > 60) {
hour = minute / 60;
minute = minute % 60;
}
var mathHour = Math.floor(hour);
var mathMinute = Math.floor(minute);
var mathSecond = Math.floor(second);
var diffTime = (mathHour<10?"0"+mathHour:mathHour) + ":" + (mathMinute<10?"0"+mathMinute:mathMinute)
+ ":" + (mathSecond<10?"0"+mathSecond:mathSecond);
return diffTime;
}
setInterval(function(){
var timeStr = diffTime("2017-02-26 12:10:00");
$(‘.antManageList-dataTime em‘).html(timeStr);
},1000)
标签:atime turn ftime return gettime second data man int
原文地址:http://www.cnblogs.com/duguangyan/p/6489155.html