Create DateTime from custom format
suggest changePHP is able to parse a number of date formats. If you want to parse a non-standard format, or if you want your code to explicitly state the format to be used, then you can use the static DateTime::createFromFormat
method:
Object oriented style
$format = "Y,m,d";
$time = "2009,2,26";
$date = DateTime::createFromFormat($format, $time);
Procedural style
$format = "Y,m,d";
$time = "2009,2,26";
$date = date_create_from_format($format, $time);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents