![]() |
VOOZH | about |
The date.toUTCString() method is used to convert the given date object's contents into a string according to the universal time zone UTC. The date object is created using the date() constructor.
dateObj.toUTCString()Note: The DateObj is a valid Date object created using the Date() constructor whose contents are converted into a string.
Example 1: Below are examples of Date toUTCString() method.
Output:
Tue, 15 Oct 1996 00:05:32 GMTExample 2: Here nothing as a parameter is passed while creating a date object but still toUTCString() method returns the current day name, month name, date, year, and time according to the universal time zone UTC.
Output:
Wed, 18 Apr 2018 08:30:48 GMTExample 3: When some random list of values is passed then toUTCString() method returns the corresponding produced string. The format for the Date() constructor is like Date(month, date, year, time). By following this format some values are given in the below program and the corresponding string is produced as output. The time format should be like (number:number: number) If time does not lie in this format, it gives the output as an Invalid date.
Output:
Sun, 31 Dec 2000 18:30:00 GMT
Fri, 02 Feb 2001 18:30:00 GMT
Tue, 04 Apr 2006 18:30:00 GMT
Invalid Date
Wed, 05 Apr 2006 05:30:12 GMT
Sat, 04 Dec 2004 18:30:00 GMTWe have a complete list of Javascript Date Objects, to check those please go through this article.
The browsers supported by JavaScript Date toUTCString() method are listed below: