jquery Display * Days * * minute * SEC implementation time Timer _jquery

Source: Internet
Author: User
Tags current time
1. Use jquery to implement the time timer, from a certain period of time to how many days from now how many minutes? How many seconds?

HTML code:
Copy Code code as follows:

<div id= "Times_wrap" class= "Time_num" >
Distance to now time:
<div class= "Time_w" >
<span id= "Time_d" class= "Time" > </span > Day
<span id= "Time_h" class= "Time" > </span >
<span id= "Time_m" class= "Time" > </span > Min
<span id= "time_s" class= "Time" > </span > Sec
</div>
</div>

<script type= "Text/javascript" >
$ (function () {

Show_time ();

});

function Show_time () {
var time_start = new Date ("2013/10/01 00:00:00"). GetTime ()/Set start time
var time_end = new Date (). GetTime (); Set end time (equals system current time)
Calculate Time Lag
var time_distance = Time_end-time_start;
if (Time_distance > 0) {
Timing and seconds conversion
var int_day = Math.floor (time_distance/86400000)
Time_distance-= Int_day * 86400000;

var int_hour = Math.floor (time_distance/3600000)
Time_distance-= Int_hour * 3600000;

var int_minute = Math.floor (time_distance/60000)
Time_distance-= Int_minute * 60000;

var int_second = Math.floor (time_distance/1000)
Time is singular, front plus 0
if (Int_day < 10) {
Int_day = "0" + int_day;
}
if (Int_hour < 10) {
Int_hour = "0" + int_hour;
}
if (Int_minute < 10) {
Int_minute = "0" + int_minute;
}
if (Int_second < 10) {
Int_second = "0" + int_second;
}
Show time
$ ("#time_d"). HTML (int_day);
$ ("#time_h"). HTML (int_hour);
$ ("#time_m"). HTML (Int_minute);
$ ("#time_s"). HTML (Int_second);

SetTimeout ("Show_time ()", 1000);

}else{
$ ("#time_d"). html (' 00 ');
$ ("#time_h"). html (' 00 ');
$ ("#time_m"). html (' 00 ');
$ ("#time_s"). html (' 00 ');

}
}
</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.