Skip to content

Instantly share code, notes, and snippets.

@jingmian
Created July 6, 2017 01:19
Show Gist options
  • Save jingmian/b5084599d6ad066c555ca8d59b94192a to your computer and use it in GitHub Desktop.
Save jingmian/b5084599d6ad066c555ca8d59b94192a to your computer and use it in GitHub Desktop.
倒时器
var starttime = new Date("2017/11/20");
setInterval(function () {
var nowtime = new Date();
var time = starttime - nowtime;
var day = parseInt(time / 1000 / 60 / 60 / 24);
var hour = parseInt(time / 1000 / 60 / 60 % 24);
var minute = parseInt(time / 1000 / 60 % 60);
var seconds = parseInt(time / 1000 % 60);
$('.timespan').html(day + "天" + hour + "小时" + minute + "分钟" + seconds + "秒");
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment