Jump to content

Incorrect strtotime() value ?


kool_samule

Recommended Posts

Hi Chaps,

 

I have a problem trying to find out the fourth Thursday of a Month of a Year, for example November.

 

date_default_timezone_set('Europe/London');

echo strtotime("November 2012 fourth thursday")."</br>"; // returns 1354147200 SHOULD BE 1353542400
echo date('Y-m-d', 1354147200)."</br>"; // returns 2012-11-29
echo date('Y-m-d', 1353542400)."</br>"; // returns 2012-11-22

 

So the problem is with the strotime calculation, I'm using PHP Version 5.2.10 on Windows/Apache.

 

Anyone know how to solve this or alternatives?

 

 

Link to comment
Share on other sites

Yeah, is this a bug, in issue with 5.2.10? Any idea of how to work around this?

 

It seems to be a problem when the DAY you are querying against happens to be the first day of the given MONTH.

I've just tried it with "October 2012 fourth Monday" and it returned: 2012-10-29, when it should be 2012-10-22..

Link to comment
Share on other sites

you are telling strtotime to select the fourth thursday AFTER the first thursday of the month, which is the 29th. you want it to say ' i want the date for the third thursaday after the first thu, so:

echo strtotime("3 weeks thursday November 1 2012");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.