有没有办法使用 JavaScript 以纳秒为单位获取当前时间? [英] Is there any way to get current time in nanoseconds using JavaScript?
本文介绍了有没有办法使用 JavaScript 以纳秒为单位获取当前时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我知道我可以使用 JavaScript 以毫秒为单位获取当前时间.但是,是否可以以纳秒为单位获取当前时间?
So, I know I can get current time in milliseconds using JavaScript. But, is it possible to get the current time in nanoseconds instead?
推荐答案
使用以下方法在大多数浏览器中实现微秒级精度:
Achieve microsecond accuracy in most browsers using:
window.performance.now()
另见:
- https://developer.mozilla.org/en-US/docs/Web/API/Performance.now()
- http://www.w3.org/TR/hr-time/一个>
- https://caniuse.com/high-resolution-time
这篇关于有没有办法使用 JavaScript 以纳秒为单位获取当前时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文