Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.prototype.toISOString

Returns the date in ISO 8601 format in UTC.

Available since: ES5

Syntax

date.toISOString()

Return value

stringA string like 2026-03-15T10:30:00.000Z in UTC.

Examples

A date in ISO:

const date = new Date(Date.UTC(2026, 2, 15, 10, 30));
 
console.log(date.toISOString());

Output:

2026-03-15T10:30:00.000Z

Just the date — the first 10 characters:

const date = new Date(Date.UTC(2026, 2, 15, 10, 30));
 
console.log(date.toISOString().slice(0, 10));

Output:

2026-03-15

Notes

The time is always converted to UTC (the Z at the end). For a user in another zone the date may be the neighbouring day: at 01:00 in Berlin it is still the previous day in UTC. This is how JSON.stringify() writes dates.

See also

Related recipes

In the tutorial

  • Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.

Thanks for reading!

Donate to the site — we work hard for you.