Is there any way to get current time in nanoseconds using JavaScript?

前端 未结 7 933
名媛妹妹
名媛妹妹 2020-11-30 12:11

So, I know I can get current time in milliseconds using JavaScript. But, is it possible to get the current time in nanoseconds instead?

7条回答
  •  [愿得一人]
    2020-11-30 12:51

    Yes! Try the excellent sazze's nano-time

    let now = require('nano-time');
    now(); // '1476742925219947761' (returns as string due to JS limitation)
    

提交回复
热议问题