Skip to content

Instantly share code, notes, and snippets.

Avatar

Chabot Vincent vchabot

View GitHub Profile
@vchabot
vchabot / createDateFromFormat.php
Last active Aug 29, 2015
Tips for \DateTime::createFromFormat method (with missing format params)
View createDateFromFormat.php
<?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"