views:

324

answers:

1

How can convert my time received from my $_GET variables as two digit values from a menu example:

$hours = 04;
$minutes = 45;
$ampm = 'PM';

into the correct format to insert into a DATETIME field in MySql

+4  A: 

If you want the DATETIME to receive that time on the current date, this'll work:

$mysql_date = date('Y-m-d H:i:s', strtotime("{$hours}:{$minutes} {$ampm}"));
ceejayoz