gpt4 book ai didi

PHP date & strtotime 添加 12 分钟?

转载 作者:行者123 更新时间:2023-12-02 07:01:01 26 4
gpt4 key购买 nike

这段代码:

date_default_timezone_set('Europe/Stockholm');
$time = date('H:m', strtotime('08:00:00'));
echo $time;

echo 08:12...为什么?我在这里错过了什么?

也在 http://writecodeonline.com/php/ 在线尝试过使用确切的此代码并得到相同的结果。我希望在几小时内出现错误,以防我做错了什么,但 12 分钟似乎很奇怪。

08:00:00 值是我数据库中的一个示例,所有时间都存储为 TIME。

最佳答案

在日期格式中,'m' 表示月,而不是分钟。尝试使用'i'。例如:

$time = date('H:i', strtotime('08:00:00'));

关于PHP date & strtotime 添加 12 分钟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20721084/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com