JavaScript toUTCString

The JavaScript toUTCString method is useful for converting a given date and time to a string format, according to the Universal Coordinated Time (UTC).

The syntax of the toUTCString method is

Date.toUTCString()

Return Value: The toUTCString date method does not accept any parameters. It returns the string representation of the given date according to the UTC zone. As toGMTString() is deprecated, we must use toUTCString() in modern coding.

JavaScript toUTCString example

In the following example, we use the toUTCString function to return the string representation of the current date and time according to Coordinated Universal Time zone. To demonstrate the difference, we print the date and time in the local time zone and the UTC zone.

const dt = new Date();
console.log(dt);
console.log(dt.toUTCString());
Tue Jun 16 2026 18:16:20 GMT+0530 (India Standard Time) 
Tue, 16 Jun 2026 12:46:20 GMT

Example 2: In this JavaScript example, we use the Date() constructor to parse a custom date. Next, the JavaScript toUTCString method converts the date object to a string as per UTC.

const dt = new Date("December 20, 2025 11:12:13");
console.log(dt);
console.log(dt.toUTCString());
Sat Dec 20 2025 11:12:13 GMT+0530 (India Standard Time) 
Sat, 20 Dec 2025 05:42:13 GMT

Example 3: If we use the toUTCString method on a date without month, day of the month, and time. It considers January 1st as the default date and time = 00:00:00.

const dt = new Date("2025");
console.log(dt);
console.log(dt.toUTCString());
Wed Jan 01 2025 05:30:00 GMT+0530 (India Standard Time) 
Wed, 01 Jan 2025 00:00:00 GMT

Example 4: If we use the toUTCString() on an invalid date, like a wrong day or month number, it returns Invalid date as output.

const dt = new Date("December 40, 2025");
console.log(dt);
console.log(dt.toUTCString());
Invalid Date 
Invalid Date