开发者

Getting current time via Javascript

开发者 https://www.devze.com 2023-01-28 12:42 出处:网络
A two-part question: What is the best way to get the current time from JavaScript? What resolution can I assume across all major platforms (including browser-capable PDAs, iPhone, etc.) -- seconds,

A two-part question:

  1. What is the best way to get the current time from JavaScript?

  2. What resolution can I assume across all major platforms (including browser-capable PDAs, iPhone, etc.) -- seconds, milliseconds,开发者_如何学JAVA 1/10th of a second?

Thanks!


  1. var date = new Date();. new Date().getTime() will return you the number of milliseconds since January 1 1970.
  2. Milliseconds. It's specified as such in the ECMAScript spec.


You can refer to this page for function work for time.

http://www.quackit.com/javascript/javascript_date_and_time_functions.cfm

There may no compatible issue. Since it is standardized

0

精彩评论

暂无评论...
验证码 换一张
取 消