Date object to a UTC string.
toUTCString() function takes a
Date object as its parameter and returns a string in UTC format. The UTC format is based on Coordinated Universal Time (UTC), which is the international time standard. UTC is the time standard that all time zones are based on, and it is always the same, regardless of where you are in the world.
toUTCString() function returns a string in the following format:
"YYYY-MM-DDThh:mm:ssZ" part of the string is the UTC time.
"YYYY" part is the year, the
"MM" part is the month, the
"DD" part is the day, the
"hh" part is the hour, the
"mm" part is the minute, and the
"ss" part is the second. The
"Z" at the end of the string indicates that the time is in UTC time.
Here is an example of how to use the
var date = new Date("July 4, 2016"); var utcString = date.toUTCString(); console.log(utcString); // "2016-07-04T19:00:00Z"
In this example, we create a new
Date object for July 4, 2016. We then use the
toUTCString() function to convert the date to a UTC string. The
console.log() function then prints the UTC string to the console.