php datetime create from string code example
Example 1: convert string to date php
$s = '08/11/2010 19:37:02';
$date = strtotime($s);
echo date('Y-m-d H:i:s', $date);
Example 2: php datetime create
$date = DateTime::createFromFormat('d-m-Y', '15-12-2020');
Example 3: create date from string php
$element = '15-Feb-2009';
$date = DateTime::createFromFormat('j-M-Y', $element);