JS Time Countdown---Excerpt others--collection

Source: Internet
Author: User

/*
Time Countdown Plugin
Timedown.js
*/
function Timedown (ID, enddatestr) {
End time
var endDate = new Date (ENDDATESTR);
Current time
var nowdate = new Date ();
Total number of seconds in difference
var totalseconds = parseint ((enddate-nowdate)/1000);
Days
var days = Math.floor (TotalSeconds/(60 * 60 * 24));
Modulo (remainder)
var modulo = totalseconds% (60 * 60 * 24);
Number of hours
var hours = Math.floor (modulo/(60 * 60));
modulo = modulo% (60 * 60);
Minutes
var minutes = Math.floor (MODULO/60);
Seconds
var seconds = modulo% 60;
Output to Page
document.getElementById (id). InnerHTML = "Still left:" + days + "Day" + Hours + "hours" + minutes + "minutes" + seconds + "seconds";
Delay one second to execute yourself
SetTimeout (function () {
Timedown (ID, ENDDATESTR);
}, 1000)
}

-----------------------------------------------------------------------------

<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Time Countdown </title>
<script src= "Timedown.js" ></script>
<body>
<form id= "Form1" runat= "Server" >
<div id= "Show" >
</div>
<script type= "Text/javascript" >
Timedown ("Show", "2013-11-25 8:00:45");
</script>
</form>
</body>

JS Time Countdown---Excerpt others--collection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.