1.JS Countdown TimerHTML code:
<p>
<span id= "test" style= "Display:block font-size:20px; font-weight:700; color: #0F0;" > Distance party start time:</span>
</p>
JS Code:
var timer; var maxtime = 3600;
One hours, in seconds, adjust yourself!
function Countdown () {if (maxtime>=0) {time = Formatminutes (maxtime);
document.getElementById ("Test"). Innerhtml=time;
if (MaxTime!=0) {--maxtime;
}else{clearinterval (timer);
}} function Formatminutes (minutes) {var day = parseint (Math.floor (minutes/86400)); var hour = Day >0?
Math.floor ((minutes-day*86400)/3600): Math.floor (minutes/3600); var minute = hour > 0?
Math.floor ((minutes-day*86400-hour*3600)/60): Math.floor (MINUTES/60); var second = minute > 0?
Math.floor (minutes-day*86400-hour*3600-minute*60): minutes;
var time= "";
if (Day > 0) Time + + + "days";
if (Hour > 0) Time + = Hour + "Hour";
if (Minute > 0) Time + = minute + "minutes";
Time + = second+ "seconds";
Time = "distance from the end of the party also:" +time;
return time;
function Dateformate (currenttimemillis) {var d = new Date ();
D.settime (Currenttimemillis); var str = D.format ("YYYY year mm month DD HH:mm:ss ");
var str = D.format ("YYYY year mm month DD Day Hh:mm:ss");
document.getElementById ("Test1"). Innerhtml= "Converted time:" +STR;}
$ (document). Ready (function () {//dateformate (' 1392818810270 ');
Timer = SetInterval ("Countdown ()", 1000); });
In the code above, call the setinterval timer, call the countdown () function every 1000 milliseconds, and the countdown implementation is reduced by one second every second to achieve
To the number timer, the global variable maxtime the time point of the countdown, which needs to be converted to a number of seconds.
The foreground effect is:
Ps:
var begindate=new date ()//start date
var enddate=new date (' 2014 ', ' 1 ', ' 25 ', ' 16 ', ' 10 ', ' 30 ');/end Date
var maxtime = Math.Round ((Enddate.gettime ()-begindate.gettime ())/1000);
The above two lines of code, you can get two points between the number of seconds, for the countdown