Tuesday, June 30, 2015

convert date in MM-DD-YYYY to YYYY-MM-DD or MM/DD/YYYY to YYYY-MM-DD in PHP

$dob = 09-14-1986;

$date = DateTime::createFromFormat('m-d-Y', $dob);
$dob = $date->format('Y-m-d');