DateTime::createFromFormat
date_create_from_format
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
DateTime::createFromFormat -- date_create_from_format — Parses a time string according to a specified format
Description
Object-oriented style
$format, string $datetime, ?DateTimeZone $timezone = null): DateTime|falseProcedural style
$format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false
Returns a new DateTime object representing the date and time specified by the
datetime string, which was formatted in the given
format.
Like DateTimeImmutable::createFromFormat() but creates an DateTime object.
The procedural version takes the DateTime object as its first argument.
Parameters
Return Values
Returns a new DateTime instance or false on failure.
See Also
- DateTimeImmutable::createFromFormat() - Parses a time string according to a specified format

