具有零小时和零分钟的PHP strtotime函数会产生意外结果
问题描述:
why it is giving me wrong result when convert the time is 00:00
. its
date_default_timezone_set("Asia/Karachi");
echo date("G:m", strtotime("00:00"));
echo date("G:m", strtotime("00:06"));
Output:
0:06
0:06
当转换时间为 输出: p>
00:00 code>时,为什么它给我错误的结果。 它的 p>
date_default_timezone_set(“Asia / Karachi”);
echo date(“G:m”,strtotime(“00:00”));
echo date(“G :m“,strtotime(”00:06“));
code> pre>
0:06
0:06
code> pre>
div>
答
Change:
"G:m"
to
"G:i" or "H:i"
m
means month, not minute (hence you see 06 for June).
G
is for hours 0-23 without preceding zeros
H
is for hours 00-23 with preceding zeros