My time in mysql is in the form hh:mm:ss
How can I convert that to 12 hour time and also remove the seconds, because they are all 00.
ex:
14:30:00
mysql
$finalresult = mysql_query("SELECT * FROM events WHERE clubID IN (" . implode(',', $clubIDs) . ") ORDER BY date ASC, TIME(startTime) ASC");
while($finalrow = mysql_fetch_assoc($finalresult)) {
$originaltime = $finalrow['startTime'];
$newtime = TIME_FORMAT($originaltime, '%h:%i %p');
}
解决方案
SELECT TIME_FORMAT('14:30:00', '%h:%i %p'); /* 02:30 PM */
Change your PHP to something like this:
$finalresult = mysql_query("SELECT Field1, Field2, TIME_FORMAT(DateField, '%h:%i %p') AS TheTime FROM events WHERE clubID IN (" . implode(',', $clubIDs) . ") ORDER BY date ASC, TIME(startTime) ASC");
This involves getting rid of * and specifying each field you want.