js method to get the current timestamp

1.Date.parse()

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

2.valueOf()

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

3.getTime()

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

4.Date.now()

var timestape=Date.now();

The screenshot of the result is as follows:

As can be seen from the above figure, the value of the timestamp obtained by Date.parse() is different from that obtained by the other two methods. That is because Date.parse() only obtains seconds, and the following milliseconds are replaced by 000, so The value of the obtained timestamp is inaccurate

Note here that the Date.now() method is not supported in installations earlier than Internet Explorer 9. However, it is supported in the following document modes: Quirks, Internet Explorer 6 Standards, Internet Explorer 7 Standards, Internet Explorer 8 Standards, Internet Explorer 9 Standards, and Internet Explorer 10 Standards. Also supported in Windows 8.x Store apps. 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326939441&siteId=291194637