猿问

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

1.我用php获取本周的周三时间到上一周的周三时间当本地时间是周日的时候获取的时间是错的

2.下面是我的代码

 $wednesdayfirst = date('Y-m-d', strtotime('this week wednesday'));
 $wednesdaylast  = date('Y-m-d', strtotime('last week wednesday'));

3.当前时间我调整到了10月的29号周日

https://img1.mukewang.com/5c8f62ea0001bfa903540145.jpg

12345678_0001
浏览 553回答 4
4回答

MMTTMM

$a = date('Y-m-d', strtotime('wednesday')); $b = date('Y-m-d', strtotime('last wednesday'));

月关宝盒

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.

慕斯王

$date1 = date('Y-m-d', strtotime('last wed')); $date2 = date('Y-m-d', strtotime('wed'));
随时随地看视频慕课网APP
我要回答