Home > Web Front-end > JS Tutorial > body text

Group buying api countdown

巴扎黑
Release: 2016-11-25 10:05:15
Original
1266 people have browsed it



<script> <br><br>function TimeTo(){ <br><br> var t = new Date(1301500800*1000),//Get the specified time Total number of milliseconds <br>         n = new Date().getTime(),//Get the current number of milliseconds <br>                                                                                                                                   using Expired or just expired, the program will be launched <br>         <br>   } <br>   var ds = 60*60*24*1000,//How many milliseconds in a day <br>   d = parseInt(c/ds),//Divide the total milliseconds by the milliseconds in a day to get the difference The number of days h = parseInt((c-d*ds)/(3600*1000)),//Then take the remaining milliseconds after the number of days and divide it by the number of milliseconds per hour to get the hour <br> m = parseInt((c - d*ds - h*3600*1000)/(60*1000)),//Subtract the remaining milliseconds from the number of days and hours, and then divide the remaining milliseconds by the number of milliseconds per minute to get minutes <br>      s = parseInt( (c-d*ds-h*3600*1000-m*60*1000)/1000);//Get the last remaining number of milliseconds divided by 1000, which is the number of seconds, and the remaining milliseconds can be automatically ignored <br>                      document.getElementById ('haha').innerHTML = '<p style="margin-top:5px;"> <b>'+d+'</b> day<b>'+h+'</b&gt ; Hours<b>'+m+'</b> Minutes</p><p class="ss"><b>'+s+'</b> Seconds</p> '; <br>//The last sentence talks about updating the defined display to the div with the ID of timer <br>setTimeout("TimeTo()", 1000); <br>} <br><br><br></script>



 




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!