Home > Web Front-end > JS Tutorial > Three ways to get the current timestamp in JS

Three ways to get the current timestamp in JS

怪我咯
Release: 2017-03-31 09:39:51
Original
3660 people have browsed it

JavaScript Get the current timestamp:

First method:

var timestamp = Date.parse (new Date());

Result: 1280977330000

Second method:

var timestamp = (new Date()).valueOf();

Result: 1280977330748

Third method:

var timestamp=new Date().getTime();

Result: 1280977330748

The first type: the timestamp obtained is to change the millisecond to 000 for display.

The second and third types are to obtain the timestamp of the current millisecond.


The above is the detailed content of Three ways to get the current timestamp in JS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template