$field->toDate()
Converts the field value to a timestamp or a formatted date
Parameters
Name | Type | Default | Description |
---|---|---|---|
$format | IntlDateFormatter |string |null |
null |
PHP date formatting string |
$fallback | string |null |
null |
Fallback string for strtotime |
Return type
string
|int
|null
Examples
To a Unix timestamp
To a formatted date string
With fallback parameter
Check out PHP's date function docs for all available formatting options: https://www.php.net/manual/en/function.date.php.
If you use the intl
date handler for localized date strings, the format syntax is different: https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax.
The strftime
date handler is deprecated as of PHP 8.1, and should not be used for new projects.