toIso8601Date.php
Table of Contents
Functions
- toIso8601Date() : string
- Converts a DateTimeInterface object to its ISO 8601 calendar date string.
Functions
toIso8601Date()
Converts a DateTimeInterface object to its ISO 8601 calendar date string.
toIso8601Date(DateTimeInterface $date[, bool $basic = false ]) : string
The output format is YYYY-MM-DD by default (ISO 8601 extended), or
YYYYMMDD if $basic is true (ISO 8601 basic).
The time and timezone components of the input are ignored; only the calendar date (year, month, day) in the object's own timezone is used.
Parameters
- $date : DateTimeInterface
-
The date to convert
- $basic : bool = false
-
If true, returns the basic format
YYYYMMDD(default: false)
Tags
Return values
string —The ISO 8601 date string, e.g. "2026-05-14" or "20260514"