문제

Basically what the title says, I have a time input for a starting hour and ending hour for some event, the input type is 00:00 AM or PM, but in Wamp server the only one that looks similar is TIME which says that supports 000;00:00 (h/m/s) would saving it like that cause an error?

Thanks.

도움이 되었습니까?

해결책

You need to convert it in Coordinated Universal Time format (HH:MM:SS). For example, 10:00PM should become 22:00:00.

From the manual:

MySQL retrieves and displays TIME values in 'HH:MM:SS' format (or 'HHH:MM:SS' format for large hours values). TIME values may range from '-838:59:59' to '838:59:59'. The hours part may be so large because the TIME type can be used not only to represent a time of day (which must be less than 24 hours), but also elapsed time or a time interval between two events (which may be much greater than 24 hours, or even negative).

To convert one time format into another in PHP is fairly easy:

$datetime = DateTime::createFromFormat('h:i A', '10:00 PM');
$time = $datetime->format('H:i:s');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top