Tuesday, 6 August 2013

Datetime->modify('second thursday') not working properly

Datetime->modify('second thursday') not working properly

I am trying to get the second thursday from a datetime.
Code
$test = new DateTime('2013-08-02 10:00');
echo $test->modify('second thursday'.$test->format('H:i'))->format('Y-m-d
H:i');
The above code returns 2013-08-15 10:00 instead of 2013-08-08 10:00
But it works correctly when I use the following code
$test = new DateTime('2013-08-02 10:00');
echo $test->modify('second
wednesday'.$test->format('H:i'))->format('Y-m-d H:i');

No comments:

Post a Comment