JS Festival Countdown Program code

Source: Internet
Author: User

Cases

Accurate to the day of the countdown

  code is as follows copy code
<script Language= "JavaScript"
<!--//(c) Henryk Gajewski
var urodz= new Date ("09/19/2013");
var  s= "Mid-Autumn Festival" ;
var now = new Date ();
var ile = Urodz.gettime ()-now.gettime ();
var dni = Math.floor (ile/(1000 * 60 * 60 * 24));
if (Dni > 1)
   document.write ("+s+" and "+dni + day")
else if (dni = 1)
   &nbs P document.write ("Only 2 days!")
Else if (dni = 0)
     document.write ("Only 1 days!")
Else
    document.write ("seems to have passed!"). ");
//;


JavaScript countdown code for accurate to second


HTML code:

The code is as follows Copy Code

<form name= "Form1" >
<div align= "center" align= "Center" >
<center> there's:<br> from 2010.
<input type= "textarea" name= "left" size= "style=" >
</center>
</div>
</form>
<script language= "JavaScript" >
Startclock ()
var timerid = null;
var timerrunning = false;
function Showtime () {
Today = new Date ();
var nowhour = today.gethours ();
var nowminute = Today.getminutes ();
var nowmonth = Today.getmonth ();
var nowdate = Today.getdate ();
var nowyear = Today.getyear ();
var nowsecond = Today.getseconds ();
if (Nowyear <2000)
Nowyear=1900+nowyear;
today = NULL;
Hourleft = 23-nowhour
Minuteleft = 59-nowminute
Secondleft = 59-nowsecond
Yearleft = 2009-nowyear
Monthleft = 12-nowmonth-1
Dateleft = 31-nowdate
if (secondleft<0)
{
Secondleft=60+secondleft;
minuteleft=minuteleft-1;
}
if (minuteleft<0)
{
Minuteleft=60+minuteleft;
hourleft=hourleft-1;
}
if (hourleft<0)
{
Hourleft=24+hourleft;
dateleft=dateleft-1;
}
if (dateleft<0)
{
Dateleft=31+dateleft;
monthleft=monthleft-1;
}
if (monthleft<0)
{
Monthleft=12+monthleft;
yearleft=yearleft-1;
}
temp=yearleft+ ' year, ' +monthleft+ ' month, ' +dateleft+ ' Day, ' +hourleft+ ' hour, ' +minuteleft+ ' minutes, ' +secondleft+ ' seconds '
Document.form1.left.value=temp;
Timerid = settimeout ("Showtime ()", 1000);
Timerrunning = true;
}
var timerid = null;
var timerrunning = false;
function Stopclock () {
if (timerrunning)
Cleartimeout (Timerid);
Timerrunning = false;
}
function Startclock () {
Stopclock ();
Showtime ();
}
-->
</script>

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.