Home > Web Front-end > JS Tutorial > Summary of methods for obtaining the current timestamp in javascript_javascript skills

Summary of methods for obtaining the current timestamp in javascript_javascript skills

WBOY
Release: 2016-05-16 15:49:04
Original
1554 people have browsed it

JavaScript to get the current timestamp:

First method:

var timestamp = Date.parse(new Date());
Copy after login

Result: 1280977330000
Second method:

var timestamp = (new Date()).valueOf();
Copy after login

Result: 1280977330748

The third method:

var timestamp=new Date().getTime();
Copy after login

Result: 1280977330748

The first method: the timestamp obtained is to change the milliseconds to 000 for display,

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

The above is the entire content of this article, I hope you all like it.

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