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