码迷,mamicode.com
首页 > 其他好文 > 详细

时间选择

时间:2017-03-02 11:26:21      阅读:177      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!