1$time = strtotime('10/16/2003');
2
3$newformat = date('Y-m-d',$time);
4
5echo $newformat;
6// 2003-10-16
7
1phpCopyecho $dateNew = DateTime::createFromFormat('m-d-Y', '03-08-2020')->format('Y/m/d');
2//output: 2020/03/08
3
1$s = '06/10/2011 19:00:02';$date = strtotime($s);echo date('d/M/Y H:i:s', $date); The above one is the one of the example of converting a string to date. echo $s ->format('Y-m-d'); The above one is another method
1phpCopy$oldDate = strtotime('03/08/2020');
2
3$newDate = date('Y-m-d',$time);
4
5echo $newDate;
6//output: 2020-03-08
7
1phpCopyecho $dateNew = date_create_from_format("m-d-Y", "03-08-2020")->format("Y-m-d");
2//output: 2020/03/08
3