1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <div id='show' style="text-align:center"></div> <script> function timeFn() { var dateBegin = Date.parse("2017-3-1"); var dateEnd = new Date(); var dateDiff = dateEnd.getTime() - dateBegin; var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)); var leave1 = dateDiff % (24 * 3600 * 1000) var hours = Math.floor(leave1 / (3600 * 1000)) var leave2 = leave1 % (3600 * 1000) var minutes = Math.floor(leave2 / (60 * 1000)) var leave3 = leave2 % (60 * 1000) var seconds = Math.round(leave3 / 1000) var leave4 = leave3 % (60 * 1000) var minseconds = Math.round(leave4 / 1000) var timeFn = "酸臭味持续了:" + dayDiff + "天" + hours + "小时" + minutes + "分钟" + seconds + "秒" + minseconds + "毫秒"; document.getElementById('show').innerText = timeFn; } setInterval("timeFn();", 1000); </script>
|