JavaScript toUTCString() Method | Novice Tutorial
\nDefinition and Usage
\nThe toUTCString() method converts a Date object to a string according to universal time (UTC).
Grammar
\ndateObject.toUTCString()\nReturn Value
\nReturns a string representation of dateObject in UTC format.
\nDescription
\nThe returned string format is: Www, dd Mmm yyyy hh:mm:ss GMT
\nField Description:
\n- \n
- Www: Day of the week abbreviation (three letters) \n
- dd: Day (two digits, if less than 10, add leading zero) \n
- Mmm: Month abbreviation (three letters) \n
- yyyy: Four-digit year \n
- hh: Hour (two digits, if less than 10, add leading zero) \n
- mm: Minute (two digits, if less than 10, add leading zero) \n
- ss: Second (two digits, if less than 10, add leading zero) \n
Browser Support
\nAll major browsers support the toUTCString() method.
Examples
\nExample 1
\nIn this example, we will convert today's date to a string according to UTC:
\nvar d = new Date();\nvar n = d.toUTCString();\ndocument.getElementById("demo").innerHTML = n;\nOutput:
\nThu,μ€ν μμ μ λ°λΌ μΆλ ₯ λ€λ¦, μ: Thu, 28 Dec 2023specific date and time> GMT\nExample 2
\nConvert a specific date object to a UTC string:
\nvar d = new Date("July 21, 1983 01:15:00");\nvar n = d.toUTCString();\ndocument.getElementById("demo").innerHTML = n;\nOutput:
\nWed, 20 Jul 1983 17:15:00 GMT\nRelated References
\n\n\n```
YouTip