process.hrtime()
是 process.hrtime.bigint()
的旧版本方法
process.hrtime(); // -> [27511, 516453000] (seconds, remaining nanoseconds)
process.hrtime.bigint(); // -> 27511516453000n (nanoseconds)
当我测试这个时间是 11:54 UTC 和 14:54 语言环境时间
最佳答案
这些值的含义在 documentation 中定义。 (虽然很容易错过,因为它只是一行):
These times are relative to an arbitrary time in the past, and not related to the time of day and therefore not subject to clock drift.
换句话说,
hrtime
仅用于计算相对于另一个时间点的时间。如果您调用hrtime
现在,然后再过十秒,后者减去前者的结果将等于十秒。然而,这两个调用返回的值彼此隔离并没有真正的意义。
关于node.js - Node.js 中的 process.hrtime() 和 process.hrtime.bigint() 函数是指什么时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56597772/