Time is a crucial element in the modern world.No matter what the work is everything happens in time. Whether it is school hours, office hours, subscription of Netflix, and so on. Programmers need to keep a track of the time to store in the databases because it has a lot of things to do than can imagine. In this article, we will look at how to get the current date and time in UTC(Universal Time Coordinated) using javascript.
Get the Current Date and Time in UTC using JavaScript
To get the current date and time in UTC, you can use toUTCString() method. This method converts a date to a string using the UTC time zone.
Syntax
toUTCString()
Return Value
A string representing the given date in the UTC time zone
Example
let UTCstring = new Date().toUTCString();
console.log(UTCstring);
Output
Wed, 12 Oct 2022 05:33:09 GMT
You can use getUTC methods that return date and time according to universal time.
Example
let date = new Date();
console.log(date);
console.log(date.getUTCDate());
console.log(date.getUTCMonth());
console.log(date.getUTCFullYear());
console.log(date.getUTCHours());
console.log(date.getUTCMinutes());
console.log(date.getUTCSeconds());
Output
2022-10-12T05:56:18.351Z
12
9
2022
5
56
18
Conclusion
In this article, we have discussed how to get the current date and time in UTC using javascript. Programmers need to have good knowledge of this concept because these are extensively used in web technologies related to education, stock market, cryptocurrency, payments, subscriptions, selling and marketing, and so on.

Rushabh Rupani is a Software Engineer with over eight years of experience. He has developed a strong foundation in computer science principles and a passion for problem-solving. Rushabh has experience with various programming languages and technologies, including PHP, Python, and expert in JavaScript. He is comfortable working in front-end and back-end development.