php – 使用strtotime在一个月内获得第一个工作日

我想使用strtotime找出一个特定月份的第一个星期三,但是第一个星期三发生在第一个星期三的时候,“第一个星期三”的参数就会失败.

有关此问题的更一般说明,请参阅以下代码和结果:

$mon = strtotime("December 2010 first monday");
$tue = strtotime("December 2010 first tuesday");
$wed = strtotime("December 2010 first wednesday");
$thu = strtotime("December 2010 first thursday");
$fri = strtotime("December 2010 first friday");
$sat = strtotime("December 2010 first saturday");
$sun = strtotime("December 2010 first sunday");

echo strftime("%m/%d/%y",$mon) . "<br>";
echo strftime("%m/%d/%y",$tue) . "<br>";
echo strftime("%m/%d/%y",$wed) . "<br>";
echo strftime("%m/%d/%y",$thu) . "<br>";
echo strftime("%m/%d/%y",$fri) . "<br>";
echo strftime("%m/%d/%y",$sat) . "<br>";
echo strftime("%m/%d/%y",$sun) . "<br>";

结果是:

12/06/10
12/07/10
12/08/10
12/02/10
12/03/10
12/04/10
12/05/10

注意事项本周的一天不应与本月1日相符?但是它从来没有,而是在第八天的第二天,总是回归.

有人有解释吗?

我没有任何解释,我也很眩目,但是我设法找出如何通过省略“第一”来获得正确的日期,就像这样:
$PHP -r 'echo date("m/d/y",strtotime("December 2010 Wednesday"));'
12/01/10

$PHP -r 'echo date("m/d/y",strtotime("December 2010 Thursday"));'
12/02/10

$PHP -r 'echo date("m/d/y",strtotime("December 2010 Friday"));'
12/03/10

$PHP -r 'echo date("m/d/y",strtotime("December 2010 Saturday"));'
12/04/10

$PHP -r 'echo date("m/d/y",strtotime("December 2010 Sunday"));'
12/05/10

$PHP -r 'echo date("m/d/y",strtotime("December 2010 Monday"));'
12/06/10

$PHP -r 'echo date("m/d/y",strtotime("December 2010 Tuesday"));'
12/07/10

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...