Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-05-16 15:49:041516browse

JavaScript to get the current timestamp:

First method:

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

Result: 1280977330000
Second method:

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

Result: 1280977330748

The third method:

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

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.

Statement:
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