Skip to content

Instantly share code, notes, and snippets.

View vchabot's full-sized avatar

Chabot Vincent vchabot

View GitHub Profile
@vchabot
vchabot / createDateFromFormat.php
Last active August 29, 2015 14:27
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"