从实现一个倒计时功能来搞清楚日期计算

先贴代码以及占坑

function startTime(duration, display) {
  var timer = duration, minutes, seconds;
  setInterval(() => {
    hour = parseInt(timer / 60*60 % 24, 10)
    minutes = parseInt(timer / 60 % 60, 10)
    seconds = parseInt(timer % 60, 10);
    
    hou
    minutes = minutes < 10 ? '0' + minutes : minutes;
    seconds = seconds < 10 ? '0' + seconds : seconds;

    display.text(minutes + ':' + seconds);
    if(--timer < 0) {
      timer = duration;
    }

  }, 1000)
}

你可能感兴趣的:(从实现一个倒计时功能来搞清楚日期计算)