Example 1 — Basic toString() Output
Print the default local date-and-time string for a fixed local datetime.
const event = new Date("August 19, 1975 23:15:30");
console.log(event.toString());
// e.g. "Tue Aug 19 1975 23:15:30 GMT+0530 (India Standard Time)"
// (offset and name depend on your timezone) How It Works
- Parse a local datetime. The string is interpreted in the runtime’s local zone.
- Call toString. Returns weekday, month, day, year, clock, and GMT offset text.
- Expect local variation. The same call shows different offsets on different machines.
- No side effects. The
Dateis unchanged; only a string is returned.

