简体   繁体   English

PHP“本周的第一天”返回上个月

[英]PHP “first date of this week” return last month

Running 跑步

var_dump(new \DateTime('first day of this week'));

Returns the 1st of September 返回9月1日

https://3v4l.org/GIPKR https://3v4l.org/GIPKR

Is this a bug, and is there any workaround? 这是一个错误,是否有任何解决方法?

在此处输入图片说明

请尝试以下代码:

var_dump(new \DateTime('monday this week'));

Refer to this - Finding First day of week via php Also try this - 参阅此- 通过php查找每周的第一天也尝试一下-

        <?php 
            // var_dump(new \DateTime('first day of this week'));


            echo date("Y-m-d", strtotime('monday this week')), "<br/>\n";   

            echo date("Y-m-d", strtotime('sunday last week')), "<br/>\n";

        ?>

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

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