Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tips for \DateTime::createFromFormat method (with missing format params)
<?php
// @see http://php.net/manual/fr/datetime.createfromformat.php
$date = \DateTime::createFromFormat('Ymd', '20140501');
var_dump($date->format('Y-m-d H:i:s')); // string(19) "2014-05-01 16:09:40" (system time)
$date = \DateTime::createFromFormat('!Ymd', '20140501');
var_dump($date->format('Y-m-d H:i:s')); // string(19) "2014-05-01 00:00:00"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment