Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  98] [ 3]  / answers: 1 / hits: 72825  / 9 Years ago, fri, june 12, 2015, 12:00:00

What is the difference between performance.now() and Date.now()?



Should I consider performance.now() as a replacement for Date.now() since performace.now() is more consistent and independent?


More From » time

 Answers
8

They both serve different purposes.



performance.now() is relative to page load and more precise in orders of magnitude. Use cases include benchmarking and other cases where a high-resolution time is required such as media (gaming, audio, video, etc.)



It should be noted that performance.now() is only available in newer browsers (including IE10+).



Date.now() is relative to the Unix epoch (1970-01-01T00:00:00Z) and dependent on system clock. Use cases include same old date manipulation ever since the beginning of JavaScript.



See When milliseconds are not enough: performance.now and now method (Internet Explorer) - MSDN for more information.



The official W3C spec can be found here: High Resolution Time API


[#66232] Wednesday, June 10, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leog

Total Points: 225
Total Questions: 113
Total Answers: 118

Location: Oman
Member since Wed, Apr 12, 2023
1 Year ago
;