具有零小时和零分钟的 PHP strtotime 函数给出了意外的结果


PHP strtotime function with zero hours and zero minutes give unexpected result

为什么在转换时间时给我错误的结果00:00 .

date_default_timezone_set("Asia/Karachi");
echo  date("G:m", strtotime("00:00"));
echo  date("G:m", strtotime("00:06"));

输出:

0:06
0:06

更改:

"G:m"

  "G:i" or "H:i"

m的意思是月,而不是分钟(因此你看到 06 代表六月)。

G 表示小时 0-23,不带前置零

H 表示小时 00-23,前面有零

http://php.net/manual/en/function.date.php