为了账号安全,请及时绑定邮箱和手机立即绑定

获取本周的周三到上周的周三 但是周日的时候时间老是不对

获取本周的周三到上周的周三 但是周日的时候时间老是不对

PHP
12345678_0001 2019-03-06 13:27:25
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'));
查看完整回答
反对 回复 2019-03-18
?
月关宝盒

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.

查看完整回答
反对 回复 2019-03-18
?
慕斯王

TA贡献1864条经验 获得超2个赞

$date1 = date('Y-m-d', strtotime('last wed'));

$date2 = date('Y-m-d', strtotime('wed'));
查看完整回答
反对 回复 2019-03-18
  • 4 回答
  • 0 关注
  • 552 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信