JS implementation of the countdown effect code is as follows:
1<!doctype html>234<meta charset= "Utf-8" >5<title> Untitled Document </title>h6<style>7 #box {8width:100%;9 height:400px;Ten Background:black; One color: #fff; Afont-size:40px; -line-height:400px; -text-Align:center; the } -</style> -<script> -Window.onload =function(){ + varOBox = document.getElementById (' box '); - varOdate =NewDate ();//gets the current time; +Odate.setfullyear (2016,11,31);//automatic rounding; AOdate.sethours (0,0,0,0); at - functioncountdown () { - //the time stamp of the future timestamp minus the current time; - varms = Odate.gettime ()-NewDate (). GetTime (); - - //milliseconds converted into seconds in varOSec = parseint (ms/1000); - to //seconds to convert all day + varOday = parseint (osec/86400); - the //less than the number of seconds left in a day; *osec%=86400; $ Panax Notoginseng //convert into Hours - varOhour = parseint (osec/3600); the + //the number of seconds left in less than an hour; Aosec%=3600; the + //convert into minutes - varOmin = parseint (OSEC/60); $ $ //the number of seconds left in less than one minute; -Osec%=60; - theobox.innerhtml = ' Distance December 31, 2016 ': ' +oday+ ' +ohour+ ' +omin+ ' +osec+ ' seconds '; - } Wuyi countdown (); theSetInterval (countdown,1000); - } Wu</script> - About $<body> -<div id= "box" > Distance December 31, 2016 also: xx days xx xx xx seconds </div> -</body> -Implementation results in the following:
Timestamp:January 1970 to present number of milliseconds: Odate.gettime ();//Don't ask me why it is January 1970 so far Oh! Baidu!
Time object:
Get Time:
var odate = new Date ();
oyear = Odate.getfullyear ();
OMon = Odate.getmonth ();
oday = Odate.getdate ();
Ohou = Odate.gethours ();
omin = Odate.getminutes ();
OSec = Odate.getseconds ();
Oweek = Odate.getday ();
Set Time:
Odate.setfullyear (year, month, day);
Odate.setmonth (month);
odate.setdate (Sun);
odate.sethours (hours, minutes, seconds, milliseconds);
time is automatically rounded up;
Probably finishing on these, there are a lot of deficiencies, I hope you have more valuable advice! Learn from each other! Learn from each other! ~ ~ ^_^
JS implementation countdown and Time object