#[DateTime]

Attribute on parameters and properties.

use WebCodingCat\WpAppFramework\Value\DateTime;

Marks a string as a date with a time of day, 2026-11-14T20:00, or with time: false as a date, 2026-11-14; '' means no date. The value is the local time of the site, without time zone: the time an editor chose, as it is shown on the site. Its schema gets a pattern, so WordPress rejects other formats, and the value factory also rejects dates that do not exist, such as 2026-02-30. Editors choose it with the date picker of WordPress. Values in this format sort and compare as text, so queries use the conditions of a string field (greaterOrEqual(), between()) and sort by it.

Arguments

#[DateTime(bool $time = true)]
ParameterTypeDefaultDescription
timebooltrueWith the time of day (hours and minutes); false for a date alone.