Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php strotime“;上周五2012年4月”;上周五不回来了_Php_Strtotime - Fatal编程技术网

php strotime“;上周五2012年4月”;上周五不回来了

php strotime“;上周五2012年4月”;上周五不回来了,php,strtotime,Php,Strtotime,当我运行下面的代码时,我得到的是4月30日,而不是27日 strtotime("Last Friday April 2012"); 我试着把它当作一个星期四来运行,结果在29日就回来了 下面所有的工作都很好 strtotime("First Sunday February 2012"); strtotime("Third Monday February 2012"); strtotime("Second Monday October 2012"); strtotime("Fourth Thur

当我运行下面的代码时,我得到的是4月30日,而不是27日

strtotime("Last Friday April 2012");
我试着把它当作一个星期四来运行,结果在29日就回来了

下面所有的工作都很好

strtotime("First Sunday February 2012");
strtotime("Third Monday February 2012");
strtotime("Second Monday October 2012");
strtotime("Fourth Thursday November 2012");

有什么想法吗?

我相信你会在3月30日而不是4月30日回来,对吗

上周五2012年4月
执行以下操作:

  • 2012年4月
    将日期设置为2012-04-01
  • 上周五
    将日期移到上一(上)周五,即2012年3月30日
如果您想要4月的最后一个星期五,请使用
2012年5月的最后一个星期五

请参阅PHP手册。

您还可以使用:

strtotime("last friday of April 2012");

echo date( 'F jS, Y h:i:s A', strtotime("last friday of April 2012"));
这将输出所需的日期:

April 27th, 2012 12:00:00 AM

strotime是垃圾输入、垃圾输出的一个很好的例子——你的短语不够具体,所以strotime猜错了。