Implement the Olympic Countdown code using JavaScript

Source: Internet
Author: User
JS countdown to Olympics Code
Transferred from: JS China
Http://javascriptxml.5d6d.com/thread-4-1-1.html
< Div >
< Div class = " Bjday " ID = " TimeDate " Width = " 60 " >
</ Div >
< Div class = " Bjtim " ID = " Times " >
</ Div >
< Script >

VaR Now =   New Date ();
Function Createtime (){

VaR GRT =   New Date ( " 8/08/2008 20:00:00 " );

Now. settime (now. gettime () + 250 );
Days = (GRT - Now) /   1000   /   60   /   60   /   24 ;
Dnum = Math. Floor (days );
Hours = (GRT - Now) /   1000   /   60   /   60   - ( 24   * Dnum );
Hnum = Math. Floor (hours );
If (String (hnum). Length = 1 ) {Hnum =   " 0 "   + Hnum ;}
Minutes = (GRT - Now) /   1000   / 60   - ( 24   *   60   * Dnum) - ( 60   * Hnum );
Mnum = Math. Floor (minutes );
If (String (mnum). Length = 1 ) {Mnum =   " 0 "   + Mnum ;}
Seconds = (GRT - Now) /   1000   - ( 24   *   60   *   60   * Dnum) - ( 60   *   60   * Hnum) - ( 60   * Mnum );
Snum = Math. Round (seconds );
If (String (snum). Length = 1 ) {Snum =   " 0 "   + Snum ;}

Document. getelementbyid ( " TimeDate " ). Innerhtml = Dnum;
Document. getelementbyid ( " Times " ). Innerhtml = Hnum +   " <Span style = 'margin: 0 7px 0 7px '>:</span> " + Mnum +   " <Span style = 'margin: 0 7px 0 7px '>:</span> " + Snum;
}

Setinterval ( " Createtime () " , 250 );

</ Script >
</ 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.