这是查询的工作版本。我只需要用AS保存新值。感谢Andy。
$Wednesday = mysqli_query($conn, "SELECT *,TIME_FORMAT(class_start,'%l:%i %p') AS new_class_start,TIME_FORMAT(class_end,'%l:%i %p') AS new_class_end
FROM wednesday INNER JOIN classes_new ON wednesday.classes_id=classes_new.classes_id WHERE classes_status='0' AND class_start NOT LIKE ''ORDER BY class_start;");
当我运行查询时,我有一个包含两个数据类型TIME列的表,时间值返回为hh:mm:ss。我想把它转换成h:mm AMPM。我尝试过使用javascript,但我确信这在MySQL中是可行的。我试图使用TIME_FORMAT,但我认为我的语法错误。运行以下查询后,将在while循环中回显值。请告知转换时间值的最佳方法。 谢谢!
$Wednesday = mysqli_query($conn, "SELECT *,TIME_FORMAT(wednesday.class_start,'%h:%i %p')
FROM wednesday INNER JOIN classes_new ON wednesday.classes_id = classes_new.classes_id WHERE classes_status =' 0' AND class_start NOT LIKE'' ORDER BY class_start;");
答案 0 :(得分:1)
这应该有效
TIME_FORMAT(your_time,"%h:%i %p") AS your_time_formatted;
修改<!/强> 添加了AS