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
https://forums.phpfreaks.com/topic/265989-incorrect-strtotime-value/
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..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.