DateTime::createFromFormat
PHP 5 >= 5.3.0, PHP 7, PHP 8
DateTime::createFromFormat - Parses a time string according to a specified format
Example #1 Intricacies of DateTime::createFromFormat
Result: Current time: 2010-04-23 10:29:35
Format: Y-m-d; 2009-02-15 10:29:35
Format: Y-m-d H:i:s; 2009-02-15 15:16:17
Format: Y-m-!d H:i:s; 1970-01-15 15:16:17
Format: !d; 1970-01-15 00:00:00
Example #2 DateTime::createFromFormat example
Result: 2009-02-15
Example #3 Format string with literal characters
Result: 23:15:03