简体   繁体   English

php 日期可能的错误

[英]php date possible bug

I found a possible bug in PHP date function, if you run this code:如果运行此代码,我在 PHP 日期 function 中发现了一个可能的错误:

date('Y-m-d', strtotime('first monday 2020-06'));

the output is 2020-06-08 instead of 2020-06-01, is this a bug or i'm doing something wrong? output 是 2020-06-08 而不是 2020-06-01,这是一个错误还是我做错了什么?

You need to put an "of" between first monday and the date date('Ym-d', strtotime('first monday of 2020-06 '));您需要在第一个星期一和日期date('Ym-d', strtotime('first monday of 2020-06 ')); You can read about it at relative Formats您可以在相关格式中阅读它

You can write first monday of june 2020 in strtotime() like below:您可以在 strtotime() 中写下 2020 年 6 月的第一个星期一,如下所示:

echo date('Y-m-d', strtotime("first monday of june 2020"));

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

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