Jump to content

strtotime() "second Saturday" bug(?)/issue


bf_ddc

Recommended Posts

Hello,

 

I am currently running into a strange issue on months that start with a single Saturday in the first week, such as August 2009 and May 2010. (Where the first day of the month (Saturday) is the only day in the first "week".)

 

When using strtotime("second Saturday") it always returns the 3rd Saturday, e.g. the 15th instead of the 8th. It seems to skip the first instance of the 1st of the month being a Saturday. Which is currently throwing off all instances of this kind of repetition in my script.

 

I have checked this on both PHP 5.2.5 and 5.2.0.

 

Is this a known issue/bug, or is it meant to be like this? Or is it solved in a later version of PHP?

 

Thanks for your time.

Link to comment
https://forums.phpfreaks.com/topic/170654-strtotime-second-saturday-bugissue/
Share on other sites

Also, tested in September 2009, which starts the 1st as a Tuesday. "first Tuesday" returns the 8th instead of the 1st. BUT-- "first Wednesday" returns the 2nd which is correct. Both Tuesday and Wednesday have a total of 5 weeks in the month of Sept. '09 with a day in it. It seems it's only the day that has the 1st in the month that this function returns wrong values with.

 

Testing printout:

 

First Tuesday of September 2009: 09/08/2009 (wrong)

Second Tuesday of September 2009: 09/15/2009

Third Tuesday of September 2009: 09/22/2009

 

First Wednesday of September 2009: 09/02/2009 (correct)

Second Wednesday of September 2009: 09/09/2009

Third Wednesday of September 2009: 09/16/2009

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.