PHP 将时间从 UTC (TZD) 格式转换为“正常”格式时间
我有一个提要,它以这种格式提供时间(不是日期时间):“20:00:00.000+03:00
”
我需要将其转换为仅显示“20:00< /代码>” 我知道我可以使用 substr 并删除字符串的其余部分来做到这一点,但这看起来更像是一种 hack,让我想知道它是否会产生不好的结果。
我已经尝试过执行 date('H:m', strtotime("20:00:00.000+03:00"));
但它给了我 20:10
? ?
I have a feed that gives me times (not datetimes) in this format: "20:00:00.000+03:00
"
I need to convert it to display just "20:00
"
I know that I can do it using substr and cutting out the rest of the string, but that seems more like a hack and makes me wonder if it can produce bad results.
I already tried doing date('H:m', strtotime("20:00:00.000+03:00"));
but it gives me 20:10
??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了第一个参数之外,您做得正确:
将输出您期望的结果。
You are doing it right, except for the first argument :
Will output the result you are expecting for.
不是
H:m
,而是H:i
。检查日期格式。Not
H:m
, butH:i
. check the date format.