Last active
August 29, 2015 14:27
-
-
Save vchabot/b05cec633f855e88f7ad to your computer and use it in GitHub Desktop.
Tips for \DateTime::createFromFormat method (with missing format params)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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