Limited supportAvoid in new code. Keep only when matching existing legacy output formats is unavoidable.

Overview

toGMTString() is a legacy Date method for producing a GMT-style string. Modern code should prefer toUTCString() or explicit formatting utilities.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
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)

Syntax

JAVASCRIPT
// toGMTString() example
// See MDN Web Docs for details

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.

Powered by web-features