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

Javascript baby birth countdown implementation code_time and date

WBOY
Release: 2016-05-16 18:21:29
Original
1124 people have browsed it

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]
<script> function Clock() { var Today=new Date(); var PPQday=new Date(2010,9-1,28); var DayTime = (PPQday.getTime()-Today.getTime())/ 1000 / 60 / 60 /24; var days = parseInt(DayTime);//天 var HourTime =(DayTime - days)*24; var hours =parseInt(HourTime);//时 var MinutesTime =(HourTime-hours)*60; var minutes = parseInt(MinutesTime);//分 var SecondTime =(MinutesTime-minutes)*60; var seconds = parseInt(SecondTime); //秒 var MillisecondTime = (SecondTime-seconds)*100;//取2位 var milliseconds = parseInt(MillisecondTime);//毫秒 document.getElementById("PPQTime").innerHTML= "距宝宝出生还有 "+ days + "天"+ ForMat(hours)+"小时"+ForMat(minutes)+"分"+ForMat(seconds)+"秒"+ForMat(milliseconds)+"毫秒"; setTimeout(Clock,100); } function ForMat(data) { if(data<10) return "0"+data; else return data; } </script>The above code is mainly used JavaScript date processing skills and setTimeout achieve date refresh.
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!