1$s = '06/10/2011 19:00:02';
2$date = strtotime($s);
3echo date('d/M/Y H:i:s', $date);
1
2<?php
3$date = new DateTime('2000-01-01');
4echo $date->format('Y-m-d H:i:s');
5?>
6
7
1<?php
2$date = '27/06/2020, 04:42:43 PM';
3$date = str_replace('/', '-', $date);
4echo date('F j, Y, g:i a',strtotime($date));
5
6// output : June 27, 2020, 4:42 pm
7?>
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
1Date to string
2
3$date = "2021/03/13";
4$newdate= date('d M, Y', strtotime($date));
5echo $newdate;
1$old_date = date('l, F d y h:i:s'); // returns Saturday, January 30 10 02:06:34
2$old_date_timestamp = strtotime($old_date);
3$new_date = date('Y-m-d H:i:s', $old_date_timestamp);
4