且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从 PHP 中的日期时间获取 AM/PM

更新时间:2023-11-05 11:56:28

您需要将其转换为 UNIX 时间戳(使用 strtotime),然后使用 日期 函数.

You need to convert it to a UNIX timestamp (using strtotime) and then back into the format you require using the date function.

例如:

$currentDateTime = '08/04/2010 22:15:00';
$newDateTime = date('h:i A', strtotime($currentDateTime));