JavaScript Date toString(): Convert a Date to Text

Date.prototype.toString() returns a string representation of a Date using the local time zone. It typically includes weekday, date, local time, UTC offset and a time-zone description.

Syntax:

date.toString();

Example:

const date = new Date(2026, 8, 10, 14, 20, 30);
const text = date.toString();
console.log(text);

What Date toString() Returns Top ↑

The returned value is a string and does not change the Date object.

const date = new Date();
const value = date.toString();
console.log(typeof value); // "string"

Automatic Date-to-String Conversion Top ↑

JavaScript often converts a Date to text automatically in string contexts. Calling toString() explicitly is clearer when the conversion itself matters.

const date = new Date();
console.log("Current date: " + date);
console.log(date.toString());

Using String Methods on the Returned Text Top ↑

The original page correctly showed that String methods become available after conversion. Use modern methods such as slice() rather than legacy substr() for new examples.

const date = new Date();
const text = date.toString();
console.log(text.slice(4));

toString() vs toDateString() Top ↑

toDateString() returns only the local date portion; toString() includes both date and time.

const date = new Date(2026, 8, 10, 14, 20, 30);
console.log(date.toDateString());
console.log(date.toString());

toString() vs toISOString() Top ↑

toISOString() returns a standardized UTC representation ending in Z. Prefer it for data interchange when an ISO UTC timestamp is appropriate.

const date = new Date();
console.log(date.toString()); // local representation
console.log(date.toISOString()); // UTC ISO representation

Use toLocaleString() for User-Facing Localization Top ↑

For locale-aware user display, use toLocaleString() or Intl.DateTimeFormat instead of manually parsing the output of toString().

Invalid Date Output Top ↑

const invalid = new Date(NaN);
console.log(invalid.toString()); // "Invalid Date"

Do Not Use toString() as a Storage Contract Top ↑

The text is designed for human-readable local representation, not as a stable database or API format. Store a timestamp or a defined interchange format instead, and format it for users at the presentation layer.

Common Date toString() Mistakes Top ↑

  • Assuming the output is UTC.
  • Expecting the same time-zone wording on every runtime.
  • Parsing pieces from the string when Date getters or Intl formatting options are available.
  • Using it as a persistent machine-readable format.

Next: toLocaleString() Date Reference




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer