PHP strtotime() “first monday february” returns second monday if february 1st is a monday

后端 未结 2 399
栀梦
栀梦 2020-12-07 02:20

I\'m working on a PHP function which calculates holidays:

function holidays($country = 1, $timespan_start = 0, $timespan_end = 0)

The holid

相关标签:
2条回答
  • 2020-12-07 02:43

    Looks like you are just missing an "of":

    echo date('Y-m-d', strtotime('first monday of february 2010'));
    

    will give the expected result. See the PHP Manual on Relative dates for the various input formats.

    0 讨论(0)
  • 2020-12-07 02:54

    Depending on your version of PHP the 'of' statement may or may not work. As another solution try:

    echo date('Y-m-d',strtotime('monday February 2010'));

    will return the first monday of February 2010. Works for all days as well.

    0 讨论(0)
提交回复
热议问题