我正在尝试从用户的当前日期开始创建一个选择列表.我希望它以 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') 返回不正确的时间?
发布评论