strtotime('today') 返回不正确的时间?

编程入门 行业动态 更新时间:2024-10-28 06:34:59
本文介绍了strtotime('today') 返回不正确的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试从用户的当前日期开始创建一个选择列表.我希望它以 unix 时间戳格式设置为午夜.

I am trying to create a select list starting from the current date of the user. I want it so that it is set to midnight in unix timestamp format.

这就是我所做的:

$today = strtotime('today'); echo $today;

这是我的结果:

1333144800

即:根据 Epoch Converter,格林威治标准时间 2012 年 3 月 30 日星期五 22:00:00(错误几个小时.)

which is: Fri, 30 Mar 2012 22:00:00 GMT according to Epoch Converter (incorrect by a couple hours.)

推荐答案

如果您希望 strtotime() 返回相对于 UTC 的时间戳(00:00:00 UTC 而不是 00:00:00 UTC+2,如果您的系统设置为相对于 UTC/GMT 偏移 2 小时的时区,您需要指定:

If you want strtotime() to return a timestamp relative to UTC (00:00:00 UTC instead of e.g. 00:00:00 UTC+2, if your system is set to a timezone with an offset of 2 hours against UTC/GMT), you need to specify that:

$today = strtotime('today UTC');

更多推荐

strtotime('today') 返回不正确的时间?

本文发布于:2023-10-16 11:21:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497411.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不正确   时间   strtotime   today

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!