定时器

body样式
 00
  :
  00
  :
  00
  
  
  
  
 
 
public.js
/*
  功能:计算两个日期的时间差
  参数:
    start 开始时间对象
    end 结束时间对象

*/
function getDiff(start, end) {
  // 总毫秒差
  var temp = end - start;
  // 小时
  var hours = parseInt(temp / 1000 / 60 / 60);
  hours = hours < 10 ? '0' + hours : hours;
  // 分钟
  var minutes = parseInt(temp / 1000 / 60 % 60);
  minutes = minutes < 10 ? '0' + minutes : minutes;
  // 秒
  var seconds = parseInt(temp / 1000 % 60);
  seconds = seconds < 10 ? '0' + seconds : seconds;
  // 返回多个值
  return {xiaoShi:hours,fenZhong:minutes,miao:seconds,temp:temp};
}

转载于:https://www.cnblogs.com/lljun/p/11470409.html

你可能感兴趣的:(定时器)