JavaScript Date toString() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

Definition

Date.prototype.toString() returns a string for this instant in the local timezone, including both date and time (plus GMT offset and often a timezone name). It is the default string form you see in the console, and it equals toDateString() + a space + toTimeString().

Remember
date.toString()

→ "Tue Aug 19 1975 23:15:30 GMT±… (…)"
→ "Invalid Date"   (if the Date is invalid)

Composition:
  toDateString() + " " + toTimeString()  ===  toString()

toISOString()     → UTC portable "…Z"
toLocaleString()  → locale-aware UI label
toUTCString()     → UTC English text

Syntax

Call date.toString. Start with this line.

JavaScript
date.toString()
CallWhat it does
date.toString()Primary signature.
date.toString(...)Call with the arguments your case needs.

Built into JavaScript. Call toString(...) on a Date instance — no import required.

Library declarations
JavaScript
date.toString()

Parameters

This method has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*The value returned by date.toString().

JavaScript Examples

Example 1 — Basic toString() Output

Print the default local date-and-time string for a fixed local datetime.

JavaScript
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)
Try It Yourself

How It Works

  1. Parse a local datetime. The string is interpreted in the runtime’s local zone.
  2. Call toString. Returns weekday, month, day, year, clock, and GMT offset text.
  3. Expect local variation. The same call shows different offsets on different machines.
  4. No side effects. The Date is unchanged; only a string is returned.

Example 2 — toString() vs Date and Time Parts

Prove that the full string is the date part plus the time part.

JavaScript
const event = new Date("August 19, 1975 23:15:30");

console.log(event.toDateString());
console.log(event.toTimeString());
console.log(event.toString());
console.log(event.toDateString() + " " + event.toTimeString() === event.toString());
// true
Try It Yourself

How It Works

  1. Read the date half. toDateString() keeps weekday + calendar fields.
  2. Read the time half. toTimeString() keeps clock + offset text.
  3. Read the full string. toString() is both parts with one space.
  4. Confirm equality. Joining the halves matches toString() exactly.

Example 3 — Guard Against Invalid Dates

Check getTime() before relying on a string label.

JavaScript
const bad = new Date("not-a-date");

if (Number.isNaN(bad.getTime())) {
  console.log("Bad input");
} else {
  console.log(bad.toString());
}
// without the guard: "Invalid Date"
Try It Yourself

How It Works

  1. Create an invalid Date. Bad input yields a NaN time value.
  2. Detect early. Number.isNaN(bad.getTime()) is true.
  3. Show a clear message. Prefer "Bad input" over a confusing label.
  4. Without a guard. toString() returns the string "Invalid Date".

Browser & Runtime Support

Date.prototype.toString() has been in JavaScript since ES1. It is Baseline and works in every modern browser and Node.js — no polyfill needed.

✓ Baseline · ES1

Date.prototype.toString()

Supported everywhere Date exists: Chrome, Firefox, Safari, Edge, Internet Explorer, and all Node.js versions.

99% Universal API
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Date.toString() Excellent

Bottom line: Safe everywhere. Remember it is local debug text — use ISO for APIs and locale methods for UI. See also the MDN toString() reference.

Frequently Asked Questions

A local date-and-time string such as "Tue Aug 19 1975 23:15:30 GMT+0530 (India Standard Time)". Exact offset and timezone name vary by machine. Invalid dates return "Invalid Date".
toString() joins those two: toDateString() + a space + toTimeString(). Same instant, three complementary views.
For Date objects, yes — String(date), `${date}`, and date + "" go through string conversion that ends up using toString().
No. Prefer toISOString() or toJSON() for portable UTC timestamps. toString() is local and not meant for data interchange.
toString() uses a fixed engine layout. toLocaleString() follows Intl locale rules and accepts locales/options for user-facing UI.
No. It is read-only — it returns a new string and leaves the Date unchanged.

Next: toTimeString()

Learn how to read only the local clock + GMT offset half of a Date string.

toTimeString() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful