<!DOCTYPE html> <html lang = "en"> <head> <meta charset = "UTF-8"> <title>js时间日期_倒计时</title> </head> <style> div { height: 300px; line-height: 300px; text-align: center; color: #FFF; font-size: 20px; background-color: pink; } </style> <body> <div> <p></p> </div> <script src = "https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script> <script> $(function () { setInterval(function () { var t = new Date('2019/02/05 00:00:00').getTime() - new Date().getTime(); $('p')[0].innerHTML = '距离春节还有' + parseInt(t / 1000 / 60 / 60 / 24) + '天' + parseInt(t / 1000 / 60 / 60) % 24 + '小时' + parseInt(t / 1000 / 60) % 60 + '分钟' + parseInt(t / 1000) % 60 + '秒'; }, 1000); </script> </body> </html>