1.我用php获取本周的周三时间到上一周的周三时间当本地时间是周日的时候获取的时间是错的
2.下面是我的代码
$wednesdayfirst = date('Y-m-d', strtotime('this week wednesday'));
$wednesdaylast = date('Y-m-d', strtotime('last week wednesday'));
3.当前时间我调整到了10月的29号周日
4 回答
MMTTMM
TA贡献1869条经验 获得超4个赞
$a = date('Y-m-d', strtotime('wednesday'));
$b = date('Y-m-d', strtotime('last wednesday'));
月关宝盒
TA贡献1772条经验 获得超5个赞
This is likely the result of a bug that affected PHP versions 5.6.23 to 5.6.30, 7.0.8 to 7.0.16, and 7.1.0 to 7.1.2. It also affects the DateTime class.
这是一个 PHP 旧版本的 bug,参考:PHP strtotime wrong only on sundays
看一下你当前的 PHP 版本,我这里是 PHP 7.0.22-0,已不存在此 bug.
慕斯王
TA贡献1864条经验 获得超2个赞
$date1 = date('Y-m-d', strtotime('last wed'));
$date2 = date('Y-m-d', strtotime('wed'));
- 4 回答
- 0 关注
- 603 浏览
添加回答
举报
0/150
提交
取消
