1$theDate = new DateTime('2020-03-08');
2echo $stringDate = $theDate->format('Y-m-d H:i:s');
3
4//output: 2020-03-08 00:00:00
1phpCopy$theDate = new DateTime('2020-03-08');
2echo $stringDate = $theDate->format('Y-m-d H:i:s');
3
4//output: 2020-03-08 00:00:00
5
1$date = date_create_from_format('d M, Y', '08 Mar, 2020');
2echo $newFormat = date_format($date,"Y/m/d H:i:s");
3
4//output: 2020/03/08 00:00:00
1$dateFormat = new DateTime(); // this will return current date
2echo $stringDate = $date->format(DATE_ATOM);
3
4//output: 2020-03-08T12:54:56+01:00
1$date = explode("/",date('d/m/Y/h/i/s')
2list($day,$month,$year,$hour,$min,$sec) = $date);
3echo $month.'/'.$day.'/'.$year.' '.$hour.':'.$min.':'.$sec;
4
5//output: 03/08/2020 02:01:06
1phpCopy$date = explode("/",date('d/m/Y/h/i/s')
2list($day,$month,$year,$hour,$min,$sec) = $date);
3echo $month.'/'.$day.'/'.$year.' '.$hour.':'.$min.':'.$sec;
4
5//output: 03/08/2020 02:01:06
6