duanhan8757 2013-10-05 20:02
浏览 49
已采纳

当$ timein为null时,PHP日期(“with”,$ time)返回错误的值

I'm loading variables from an SQL query, one of which is a unix timestamp. I'm using the PHP date() function to determine the day of the week. It seems to work fine, but I noticed that when the unix timestamp is NULL, the use of date("w", $myunixtime) yields a value of 3. I'm echoing the value of the timestamp, and I get a 'blank' as I should. Then right after that, I'm echoing the value of the function, and I see the 3. This is weird, and I don't see any documentation that explains this.

I'm on a Linux server using PHP Version 5.3.10. The server is in the Eastern Time Zone, and no, I'm not using UTC and don't want to -- way too much code to change for that. This shouldn't have anything to do with that anyway.

Has anyone else noticed weird values from the date() function -- when using recent years and not the 1599-1600 year issue that you may have noticed?

  • 写回答

1条回答 默认 最新

  • douchi7073 2013-10-05 20:07
    关注

    Your empty string casted to int as 0 and timestamp of 0 is begin of unix epoch, January 1 1970 00:00:00 GMT it was a Thursday but because your timezone it UTC -4 you get a previous day — Wednesday.

    Anyway what result do you expect?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集