简体   繁体   English

PHP - strtotime 使用短语“上周的第一天”不正确

[英]PHP - strtotime using phrase "first day of last week" not correct

Using the code:使用代码:

$from_date = date("Y-m-d 00:00:00", strtotime("first day of last week"));

returns: "2020-10-01 00:00:00", when I expect it to return "2020-10-25 00:00:00".返回:“2020-10-01 00:00:00”,当我希望它返回“2020-10-25 00:00:00”时。

Why is it returning the first day of the month?为什么它返回一个月的第一天?

How can I get the first day of last week (and also the last day of last week)?如何获得上周的第一天(以及上周的最后一天)?

try this:尝试这个:

<?php

$from_date = date("Y-m-d 00:00:00", strtotime("last week last sunday"));

echo $from_date;
//returns 2020-10-25 00:00:00;

I've tested the dates on 7.1.0 version我已经测试了 7.1.0 版本的日期

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM