[英]How do you convert between 12 hour time and 24 hour time in PHP?
I have a time as a string, for example: 我有一个时间作为字符串,例如:
$time = '5:36 pm';
I require this to be in 24 hour format (ie 17:36
), however I don't know which functions I need to use to convert it. 我要求它采用24小时格式(即17:36
),但是我不知道我需要使用哪些函数来进行转换。 Please help. 请帮忙。
// 24-hour time to 12-hour time
$time_in_12_hour_format = date("g:i a", strtotime("13:30"));
// 12-hour time to 24-hour time
$time_in_24_hour_format = date("H:i", strtotime("1:30 PM"));
“ 2019-11-26 03:57:30 PM”(“ Ymd H:i:s A”)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.