这种情况是因为PHP无法识别这种格式的时间,所以将其默认为1970年1月1日的时间戳,因此输出的时间为1970-01-01 00:00:00。要将其转换为标准时间格式,可以使用PHP中的strtotime()函数将其转换为时间戳,然后再使用date()函数将其格式化为标准时间格式。例如:

$time = '25/11/2020下午4:00:00';
$timestamp = strtotime(str_replace('下午', 'PM', $time));
echo date('Y-m-d H:i:s', $timestamp);

输出结果为:2020-11-25 16:00:00。

PHP时间格式转换:如何将'25/11/2020下午4:00:00'格式转换为标准时间

原文地址: https://www.cveoy.top/t/topic/lBo8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录