[英]Convert timestamp into hour with PHP
Hi I am using following way to convert timestamp into hour: 嗨,我正在使用以下方式将时间戳转换为小时:
echo time() / 3600 % 24;
This return like 7 if its 7 GTM but I need its output such as 07:00 如果它的7 GTM,则返回类似7的返回值,但是我需要它的输出,例如07:00
Please suggest. 请提出建议。
Thanks! 谢谢!
you can do this with gmdate
function 您可以使用gmdate
函数执行此gmdate
echo gmdate("H:i", time());
if you want only hours than just have only H
in gmdate
如果您只想几个小时而不是只在gmdate
有H
gmdate — Format a GMT/UTC date/time gmdate-格式化GMT / UTC日期/时间
As @Mark Baker suggest if you want fix second timer than you can manually write like 正如@Mark Baker所建议的,如果您要修复第二个计时器,则可以像这样手动编写
echo gmdate("H:00", time());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.