Iso8601Format uses ConstantsTrait
Standard ISO 8601 date and time format patterns.
Provides a single entry point for the most commonly used ISO 8601 format strings, compatible with PHP's DateTimeInterface::format().
Two representations are supported:
- Extended : separators are used (e.g.
2026-05-14T08:15:30+02:00) - Basic : separators are omitted (e.g.
20260514T081530+0200)
Example usage:
use org\iso\Iso8601Format;
$now = new DateTimeImmutable('now', new DateTimeZone('UTC'));
echo $now->format( Iso8601Format::DATE ); // "2026-05-14"
echo $now->format( Iso8601Format::DATE_TIME_ZULU ); // "2026-05-14T08:15:30Z"
echo $now->format( Iso8601Format::DATE_TIME ); // "2026-05-14T08:15:30+00:00"
Iso8601Format::includes('Y-m-d'); // true
Iso8601Format::getConstant('Y-m-d\TH:i:s\Z'); // "DATE_TIME_ZULU"
Tags
Table of Contents
Constants
- DATE : string = 'Y-m-d'
- Calendar date in extended format: `Y-m-d` (e.g. "2026-05-14").
- DATE_BASIC : string = 'Ymd'
- Calendar date in basic format: `Ymd` (e.g. "20260514").
- DATE_TIME : string = 'Y-m-d\TH:i:sP'
- Date and time in extended format with timezone offset: `Y-m-d\TH:i:sP` (e.g. "2026-05-14T08:15:30+02:00").
- DATE_TIME_BASIC : string = 'Ymd\THisO'
- Date and time in basic format with offset: `Ymd\THisO` (e.g. "20260514T081530+0200").
- DATE_TIME_BASIC_ZULU : string = 'Ymd\THis\Z'
- Date and time in basic format in UTC ("Zulu"): `Ymd\THis\Z` (e.g. "20260514T081530Z").
- DATE_TIME_LOCAL : string = 'Y-m-d\TH:i:s'
- Local date and time in extended format, without timezone: `Y-m-d\TH:i:s` (e.g. "2026-05-14T08:15:30").
- DATE_TIME_MICRO : string = 'Y-m-d\TH:i:s.uP'
- Date and time with microseconds and timezone offset: `Y-m-d\TH:i:s.uP` (e.g. "2026-05-14T08:15:30.123456+02:00").
- DATE_TIME_MICRO_ZULU : string = 'Y-m-d\TH:i:s.u\Z'
- Date and time with microseconds in UTC ("Zulu"): `Y-m-d\TH:i:s.u\Z` (e.g. "2026-05-14T08:15:30.123456Z").
- DATE_TIME_MILLI : string = 'Y-m-d\TH:i:s.vP'
- Date and time with milliseconds and timezone offset: `Y-m-d\TH:i:s.vP` (e.g. "2026-05-14T08:15:30.123+02:00").
- DATE_TIME_MILLI_ZULU : string = 'Y-m-d\TH:i:s.v\Z'
- Date and time with milliseconds in UTC ("Zulu"): `Y-m-d\TH:i:s.v\Z` (e.g. "2026-05-14T08:15:30.123Z").
- DATE_TIME_ZULU : string = 'Y-m-d\TH:i:s\Z'
- Date and time in extended format in UTC ("Zulu"): `Y-m-d\TH:i:s\Z` (e.g. "2026-05-14T08:15:30Z").
- ORDINAL_DATE : string = 'Y-z'
- ISO 8601 ordinal date: `Y-z` (e.g. "2026-134").
- TIME : string = 'H:i:s'
- Time of day in extended format, without timezone: `H:i:s` (e.g. "08:15:30").
- TIME_BASIC : string = 'His'
- Time of day in basic format: `His` (e.g. "081530").
- TIME_OFFSET : string = 'H:i:sP'
- Time of day with timezone offset: `H:i:sP` (e.g. "08:15:30+02:00").
- TIME_ZULU : string = 'H:i:s\Z'
- Time of day in UTC ("Zulu"): `H:i:s\Z` (e.g. "08:15:30Z").
- WEEK : string = 'o-\WW'
- ISO 8601 week (without day): `o-\WW` (e.g. "2026-W20").
- WEEK_DATE : string = 'o-\WW-N'
- ISO 8601 week date in extended format: `o-\WW-N` (e.g. "2026-W20-4" for the 4th day of week 20 of ISO year 2026).
- WEEK_DATE_BASIC : string = 'o\WWN'
- ISO 8601 week date in basic format: `o\WWN` (e.g. "2026W204").
- YEAR : string = 'Y'
- Year only: `Y` (e.g. "2026").
- YEAR_MONTH : string = 'Y-m'
- Year and month: `Y-m` (e.g. "2026-05").
Constants
DATE
Calendar date in extended format: `Y-m-d` (e.g. "2026-05-14").
public
string
DATE
= 'Y-m-d'
DATE_BASIC
Calendar date in basic format: `Ymd` (e.g. "20260514").
public
string
DATE_BASIC
= 'Ymd'
DATE_TIME
Date and time in extended format with timezone offset: `Y-m-d\TH:i:sP` (e.g. "2026-05-14T08:15:30+02:00").
public
string
DATE_TIME
= 'Y-m-d\TH:i:sP'
DATE_TIME_BASIC
Date and time in basic format with offset: `Ymd\THisO` (e.g. "20260514T081530+0200").
public
string
DATE_TIME_BASIC
= 'Ymd\THisO'
DATE_TIME_BASIC_ZULU
Date and time in basic format in UTC ("Zulu"): `Ymd\THis\Z` (e.g. "20260514T081530Z").
public
string
DATE_TIME_BASIC_ZULU
= 'Ymd\THis\Z'
DATE_TIME_LOCAL
Local date and time in extended format, without timezone: `Y-m-d\TH:i:s` (e.g. "2026-05-14T08:15:30").
public
string
DATE_TIME_LOCAL
= 'Y-m-d\TH:i:s'
DATE_TIME_MICRO
Date and time with microseconds and timezone offset: `Y-m-d\TH:i:s.uP` (e.g. "2026-05-14T08:15:30.123456+02:00").
public
string
DATE_TIME_MICRO
= 'Y-m-d\TH:i:s.uP'
DATE_TIME_MICRO_ZULU
Date and time with microseconds in UTC ("Zulu"): `Y-m-d\TH:i:s.u\Z` (e.g. "2026-05-14T08:15:30.123456Z").
public
string
DATE_TIME_MICRO_ZULU
= 'Y-m-d\TH:i:s.u\Z'
DATE_TIME_MILLI
Date and time with milliseconds and timezone offset: `Y-m-d\TH:i:s.vP` (e.g. "2026-05-14T08:15:30.123+02:00").
public
string
DATE_TIME_MILLI
= 'Y-m-d\TH:i:s.vP'
DATE_TIME_MILLI_ZULU
Date and time with milliseconds in UTC ("Zulu"): `Y-m-d\TH:i:s.v\Z` (e.g. "2026-05-14T08:15:30.123Z").
public
string
DATE_TIME_MILLI_ZULU
= 'Y-m-d\TH:i:s.v\Z'
DATE_TIME_ZULU
Date and time in extended format in UTC ("Zulu"): `Y-m-d\TH:i:s\Z` (e.g. "2026-05-14T08:15:30Z").
public
string
DATE_TIME_ZULU
= 'Y-m-d\TH:i:s\Z'
ORDINAL_DATE
ISO 8601 ordinal date: `Y-z` (e.g. "2026-134").
public
string
ORDINAL_DATE
= 'Y-z'
Note: PHP's z format yields a zero-based day of year (0–365), whereas
the ISO ordinal day is 1-based. Prefer building the string manually
when strict compliance is required.
TIME
Time of day in extended format, without timezone: `H:i:s` (e.g. "08:15:30").
public
string
TIME
= 'H:i:s'
TIME_BASIC
Time of day in basic format: `His` (e.g. "081530").
public
string
TIME_BASIC
= 'His'
TIME_OFFSET
Time of day with timezone offset: `H:i:sP` (e.g. "08:15:30+02:00").
public
string
TIME_OFFSET
= 'H:i:sP'
TIME_ZULU
Time of day in UTC ("Zulu"): `H:i:s\Z` (e.g. "08:15:30Z").
public
string
TIME_ZULU
= 'H:i:s\Z'
WEEK
ISO 8601 week (without day): `o-\WW` (e.g. "2026-W20").
public
string
WEEK
= 'o-\WW'
WEEK_DATE
ISO 8601 week date in extended format: `o-\WW-N` (e.g. "2026-W20-4" for the 4th day of week 20 of ISO year 2026).
public
string
WEEK_DATE
= 'o-\WW-N'
WEEK_DATE_BASIC
ISO 8601 week date in basic format: `o\WWN` (e.g. "2026W204").
public
string
WEEK_DATE_BASIC
= 'o\WWN'
YEAR
Year only: `Y` (e.g. "2026").
public
string
YEAR
= 'Y'
YEAR_MONTH
Year and month: `Y-m` (e.g. "2026-05").
public
string
YEAR_MONTH
= 'Y-m'