function daojishi(){ var starttime = new Date("2017-09-30 01:06:11"); //date的格式也可以写成:"2017/09/30 01:06:11" //其他格式还没试过 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); if (day<0 || hour<0 || minute<0 || seconds<0) { day =0; hour =0; minute =0; seconds =0; } $(".day").html(day); $(".hour").html(hour); $(".min").html(minute); $(".sec").html(seconds); }, 1000); }
时间: 2024-11-08 20:25:52