我在变量中有一个日期时间。我的格式是 08/04/2010 22:15:00
。我想像 10.15 PM
一样显示它。如何在 PHP 中做到这一点?
最佳答案
您需要将其转换为 UNIX 时间戳(使用 strtotime),然后使用 date 转换回您需要的格式。功能。
例如:
$currentDateTime = '08/04/2010 22:15:00';
$newDateTime = date('h:i A', strtotime($currentDateTime));
https://stackoverflow.com/questions/3404699/