Categories
JavaScript Answers

How to get an accurate timestamp in Node.js?

Spread the love

Sometimes, we want to get an accurate timestamp in Node.js.

In this article, we’ll look at how to get an accurate timestamp in Node.js.

How to get an accurate timestamp in Node.js?

To get an accurate timestamp in Node.js, we can use the process.hrtime.bigint method.

For instance, we write

process.hrtime.bigint()

to call process.hrtime.bigint to return the current timestamp in nanoseconds as a JavaScript bigint.

Conclusion

To get an accurate timestamp in Node.js, we can use the process.hrtime.bigint method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *