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.