<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>单个timeout</title> <script src="/Content/js/jquery-1.10.2.min.js" type="text/javascript"></script> </head> <body> <p id="countDown1"></p> <script type="text/javascript"> function getCountDown(timestamp) { var timer = setInterval(function () { var nowTime = new Date(); var endTime = timestamp; var t = endTime - nowTime.getTime(); if (t <= 0) { $("#countDown1").html('over'); clearInterval(timer); return false; } var d=Math.floor(t/1000/60/60/24); var hour = Math.floor(t / 1000 / 60 / 60 % 24); var min = Math.floor(t / 1000 / 60 % 60); var sec = Math.floor(t / 1000 % 60); if (hour < 10) { hour = "0" + hour; } if (min < 10) { min = "0" + min; } if (sec < 10) { sec = "0" + sec; } var countDownTime = d + "天 " + hour + ":" + min + ":" + sec; $("#countDown1").html(countDownTime); }, 1000); } var date = '2019-04-02 10:33:00.0'; date = date.substring(0, 19); date = date.replace(/-/g, '/'); var timestamp = new Date(date).getTime(); // 毫秒级 getCountDown(timestamp); </script> </body> </html>