时间选择
Posted duguangyan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了时间选择相关的知识,希望对你有一定的参考价值。
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)
以上是关于时间选择的主要内容,如果未能解决你的问题,请参考以下文章