Skip to content

toISOStringDate() ​

ts
function toISOStringDate(this, isLocal?): string;

Defined in: date/iso-date.ts:31

Converts a Date object to an ISO 8601 date string (YYYY-MM-DD) By default, the Date is computed in UTC (i.e. based on Date.prototype.toISOString()), which means the returned value may differ from the local calendar day if your local timezone is behind/ahead of UTC.

If isLocal is set to true, the date is instead computed using local time (getFullYear(), getMonth(), getDate()), so the string always reflects the local calendar date.

Parameters ​

ParameterTypeDefault valueDescription
thisDateundefinedDate object instance
isLocal?booleanfalseIf true, uses local time; otherwise, uses UTC time

Returns ​

string

The ISO 8601 date string

Example ​

ts
const d = new Date("2025-03-15T23:30:00Z");

// UTC-based date (default):
d.toISOStringDate();     // e.g. "2025-03-15"

// Local-time-based date:
d.toISOStringDate(true); // e.g. "2025-03-16" in a timezone ahead of UTC

Since ​

1.1.0

Author ​

Ian Wenneckers