So, I know I can get current time in milliseconds using JavaScript. But, is it possible to get the current time in nanoseconds instead?
A nanosecond (ns or nsec) is one billionth (10-9) of a second and is a common measurement of read or write access time to random access memory (RAM). Admiral Grace Hopper famously handed out foot-long lengths of wire to students to illustrate how far an electrical signal can travel in a nanosecond.
JavaScript - Date getMilliseconds() Method Javascript date getMilliseconds() method returns the milliseconds in the specified date according to local time. The value returned by getMilliseconds() is a number between 0 and 999.
now() The static Date. now() method returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.
Achieve microsecond accuracy in most browsers using:
window.performance.now()
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With