toGMTString()
The toUTCString() method of Date instances returns a string representing this date in the RFC 7231 format, with negative years allowed. The timezone is always UTC. toGMTString() is an alias of this method.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
Date.toGMTString Deprecated | 1 | 12 | 1 | 1 | 18 | 1 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Live demo
Compare toGMTString and toUTCString
Show that the legacy method mirrors the modern UTC string formatter.
JavaScript
Output
Press the Run button
Format the current time
Generate a GMT-style timestamp for the current date.
JavaScript
Output
Press the Run button
Store legacy timestamp labels
Create a small audit log with human-readable timestamps.
JavaScript
Output
Press the Run button
Use cases
-
Legacy output review
Understand older date formatting code before replacing it with clearer UTC-oriented methods.
-
Compatibility migrations
Preserve historical serialized output temporarily while modernizing a system.
Cautions
- Legacy date-formatting names make intent less clear than explicit UTC formatting APIs.
- Prefer modern formatting so date output rules remain easy to maintain and localize.
Accessibility
- Readable and correct date formatting helps all users, especially when dates are announced by assistive tools.
- Do not keep legacy formatting if it produces ambiguous strings in user-facing UI.