PHP Datetime with MySQL datetime I want to ask about change a datetime value of PHP with datetime value from MySQL data. I have try to do this at PHP: $sitgl = date('Y-m-d', strtotime(2012-01-12)); $sijam = date('H:i:s', strtotime(13:00:00)); $awal = $sitgl.' '.$sijam; $awal2 = date('Y-m-d H:i:s', strtotime($awal)); $debrangkat = strtotime($awal2); And I'm trying to convert same datetime at MySQL like this (convert it to seconds): SELECT date_start_book, time_start_book, (TO_DAYS(CAST(date_start_book AS DATE))*86400) + TIME_TO_SEC(CAST(time_start_book AS TIME)) FROM `t_request_queue` WHERE `request_id` = '1301-0087' which is
undefined
Convert from MySQL datetime to another format with PHP I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP? Solution : To convert a date retrieved from MySQL into the format requested (mm/dd/yy H:M (AM/PM)): // $datetime is something like: 2014-01-31 13:05:59 $time = strtotime($datetimeFromMysql); $myFormatForView = date("m/d/y g:i A", $time); // $myFormatForView is something like: 01/31/14 1:05 PM Refer to the PHP date formatting options to adjust the format. http://stackoverflow.com/questions/136782/convert-from-mysql-datetime-to-another-format-with-php/5367048#5367048