1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Document</title>6 <style>7 Div{8 width:1210px;9 margin:200px Auto;Ten Color:Orange; One text-align:Center; A Font:30px/30px "SimSun"; - } - </style> the </Head> - <Body> - <Div></Div> - + <Script> - varDiv=document.getElementsByTagName ("Div")[0]; + varTimer=setinterval (FN, -); A at functionfn () { - varNowtime= NewDate (); - var Future= NewDate ("2018/10/01 10:10:10"); - varTimesum=future.gettime ()-nowtime.gettime (); - var Day=parseint (Timesum/ +/ -/ -/ -); - varHour=parseint (Timesum/ +/ -/60%24); in varMinu=parseint (Timesum/ +/ -% -); - varsec=parseint (Timesum/1000%60); to //var millsec = parseint (timesum%1000); + - Day= Day< Ten? "0"+Day:day; the Hour=Hour< Ten? "0"+Hour:hour; * Minu=Minu< Ten? "0"+Minu:minu; $ sec=sec< Ten? "0"+sec:sec;Panax Notoginseng //if (Millsec <) { - //millsec = "xx" +MILLSEC; the //}else if (Millsec <) { + //millsec = "0" +MILLSEC; A // } the + if(Timesum< 0) { - div.innerhtml= "00 days, 00 hours, 00 minutes and 00 seconds from National Day"; $ clearinterval (timer); $ return; - } - div.innerhtml= "from the National Day and"+ Day+"days"+Hour+"hours"+Minu+"points"+sec+"seconds"; the } - </Script>Wuyi </Body> the </HTML>
JavaScript experience Countdown: How long is it from the National Day