New Date () Countdown function

Source: Internet
Author: User

The result of a separate call to New Date () in JS is: Fri 20:00:00 gmt+0800 time in this format

JS Gets the current timestamp method

JavaScript gets the current timestamp:
The first method:

var time =date.parse (New Date ());
Results: 1463732230000
The second method:

var time = (new Date ()). ValueOf ();
Results: 1463732231455

The third method:

var time=new Date (). GetTime ();
Results: 1463732299085

var ems = document.getElementsByTagName ("em");
var t_time = "2016/05/20 20:00:00";
S_time = new Date (t_time);
S_time = Date.parse (t_time)/1000;
(function settime () {
var n_time = date.parse (New Date ())/1000;
var time = S_time-n_time;
if (time>0) {
var d = parseint (time/86400);
Time = time-d * 86400;
var h = parseint (time/3600);
Time = time-h * 3600;
var m = parseint (TIME/60);
Time = time-m * 60;
var s = time;
ems[3].innerhtml = s;
ems[2].innerhtml = m;
ems[1].innerhtml = h;
ems[0].innerhtml = D;
SetTimeout (settime, 500);
}else {
Alert (' The countdown is over ')
}
})();

New Date () Countdown function

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.