The example of this article for everyone to parse the countdown to the detailed process of JS, for everyone's reference, the specific contents are as follows
Comments:
The parseint () function parses a string and returns an integer.
Syntax:
parseint (string, radix)
Cases:
parseint ("10"); Returns ten
parseint ("19", 10);//Return (10+9)
parseint ("11", 2);//Return 3 (2+1)
parseint ("17", 8);//Return 15 (8+7)
parseint ("1f", 16);//Return to (16+15)
parseint ("010");//undecided: return 10 or 8
Implementing the Countdown Code
HTML code:
JavaScript code:
<script language= "javascript" type= "Text/javascript" >
function Lefttimer (Year,month,day,hour,minute, Second) {
var lefttime = (new Date (Year,month-1,day,hour,minute,second))-(new Date ());//Calculate the remaining milliseconds
var days = par Seint (LEFTTIME/1000/60/60/24, 10); Calculate the remaining days
var hours = parseint (lefttime/1000/60/60% 24, 10);//Calculate remaining hours
var minutes = parseint (lefttime/1 000/60% 60, 10);//Calculate remaining minutes
var seconds = parseint (lefttime/1000% 60, 10);//Calculate the number of seconds remaining
= Checktime (days);
hours = Checktime (hours);
minutes = Checktime (minutes);
seconds = checktime (seconds);
SetInterval ("Lefttimer (2016,11,11,11,11,11)", 1000);
document.getElementById ("Timer"). InnerHTML = days+ "Day" + hours+ "hour" + minutes+ "minutes" +seconds+ "seconds";
}
function Checktime (i) {//0-9 of the number preceded by 0, example 1 changes to
if (i<10)
{
i = "0" + i;
}
return i;
}
</script>
Implementation effect:
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.