toISO

Commons
stable

Format a Date (adapter-aware) to a zero-padded `YYYY-MM-DD` ISO date string. Works with any IDateAdapter so it is locale-independent and consistent across calendar systems.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

adapter
required
IDateAdapter<any>
The date adapter instance. Its `toJsDate()` method is used to normalise the value before extracting year/month/day parts.
value
required
Date
The date to format. Passed through `adapter.toJsDate()` first.

API

Return value

The value returned by this util.

An ISO-8601 date string `YYYY-MM-DD`, e.g. "2024-06-01".

Usage

Examples

Ready-to-paste usage snippets.

Format a date with the default adapter

typescript