To convert a JavaScript date object into a UTC string, you can use the toUTCString() method of the Date object.

This method converts a Date object to a string, according to universal time zone:

const date = new Date(2021, 8, 7)

const utc = date.toUTCString()

console.log(utc)
// Mon, 06 Sep 2021 19:00:00 GMT

Note that the GTM time is the same as UTC time. The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

You could also use the Date.UTC() method to create a new Date object directly in UTC time zone. This accepts parameters similar to the Date constructor, but treats them as UTC:

const date = new Date(Date.UTC(2021, 8, 7, 12, 44, 20))

const utc = date.toUTCString()

console.log(utc)
// Tue, 07 Sep 2021 12:44:20 GMT

By default, the Date.UTC() method returns the number of milliseconds since January 1, 1970, 00:00:00 UTC. In the above example, we use new Date() to convert the milliseconds into a Date object.