kool_samule Posted July 20, 2012 Share Posted July 20, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/265989-incorrect-strtotime-value/ Share on other sites More sharing options...
Barand Posted July 20, 2012 Share Posted July 20, 2012 Strangely, it thinks the first Thursday is on the 8th Quote Link to comment https://forums.phpfreaks.com/topic/265989-incorrect-strtotime-value/#findComment-1363000 Share on other sites More sharing options...
kool_samule Posted July 20, 2012 Author Share Posted July 20, 2012 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.. Quote Link to comment https://forums.phpfreaks.com/topic/265989-incorrect-strtotime-value/#findComment-1363002 Share on other sites More sharing options...
gristoi Posted July 20, 2012 Share Posted July 20, 2012 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"); Quote Link to comment https://forums.phpfreaks.com/topic/265989-incorrect-strtotime-value/#findComment-1363005 Share on other sites More sharing options...
kool_samule Posted July 20, 2012 Author Share Posted July 20, 2012 OK my bad, thanks for the heads up. Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/265989-incorrect-strtotime-value/#findComment-1363006 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.