Categories
JavaScript Answers

How to get a UTC Date object in Node.js and JavaScript?

Spread the love

Sometimes, we want to get a UTC Date object in Node.js and JavaScript.

In this article, we’ll look at how to get a UTC Date object in Node.js and JavaScript.

How to get a UTC Date object in Node.js and JavaScript?

To get a UTC Date object in Node.js and JavaScript, we can call the date’s toUTCString method.

For instance, we write:

console.log(new Date().toUTCString())

to create a new Date instance and call toUTCString to return the UTC date string version of the current date time.

Conclusion

To get a UTC Date object in Node.js and JavaScript, we can call the date’s toUTCString 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 *