Can someone give me a quick and dirty way to split a datetime (28-1-2011 14:32:55) into just the date (28-1-2011) and the time ( 14:32 ) or even better (2:32 PM) using PHP. Using a mySQL database as well.
Cheers
If you're using PHP > 5.2:
$myvalue = '28-1-2011 14:32:55'; $datetime = new DateTime($myvalue); $date = $datetime->format('Y-m-d'); $time = $datetime->format('H:i:s');
Prior to PHP 5.2 mhitza gave a good answer.
2.1m questions
2.1m answers
60 comments
57.0k users