string to datetime php
snippet in php

php convert string to date

user3351

$time = strtotime('10/16/2003');

$newformat = date('Y-m-d',$time);

echo $newformat;
// 2003-10-16

string to datetime php

user7500

$s = '06/10/2011 19:00:02';
$date = strtotime($s);
echo date('d/M/Y H:i:s', $date);

php datetime create

user298

$date = DateTime::createFromFormat('d-m-Y', '15-12-2020');