JavaScript Countdown Code _ Time Date

Source: Internet
Author: User
JS script:
Copy Code code as follows:

<script language= "javascript" type= "Text/javascript" >
var interval = 1000;
Function Showcountdown (year, month, day, Divname) {
var now = new Date ();
var enddate = new Date (year, Month-1, day, 14, 07);
var lefttime = Enddate.gettime ()-now.gettime ();
var leftsecond = parseint (lefttime/1000);
var day1 = Math.floor (Leftsecond/(60 * 60 * 24));
var hour1 = Math.floor (leftsecond-day1 * 24 * 60 * 60)/3600);
var hour = Math.floor (leftsecond-60 * 60)/3600);
If the hour is a negative number show 0
if (Hour > 0) {
}
else {
hour = 0;
}
if (Day1 < 0) {
hour = Hour1
}
var minute = Math.floor (leftsecond-day1 * 60-HOUR1 * 3600)/60);
var second = Math.floor (leftsecond-day1 * * 60-HOUR1 * 3600-minute * 60);
var cc = document.getElementById (divname);
Displays 0 if the end time is negative
if (Lefttime > 0) {
Cc.innerhtml = Hour + "Hour" + Minute + "min" + second + "seconds";
If the year is displayed uncomment
cc.innerhtml = "Distance" + year + "years" + month + "Month" + Day + "Days also:" + hour + "hours" + Minute + "min" + second + "seconds";
}
else {
cc.innerhtml = 0 + "Hour" + 0 + "min" + 0 + "seconds";
}
}
ShowData is the div ID 2010,8,10 indicates that the mean parameter is set according to its own requirements.
Window.setinterval (function () {Showcountdown (8, ' ShowData ');}, Interval);
</script>

Add the following code where you want the time to appear:
Copy Code code as follows:

<div id= "ShowData" >
</div>

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.