September 1st, 2014


there's more than one wrong way to do it

just a reminder: I like programming, but I'm a hack at it.

I wrote a calendar sort of thing that reported out what the first saturday of the month was, for the next 12 months. It worked great. PHP has this function called "strtotime" that converts a string (any text) to a timestamp... so I just put in "+1 month" so it would tell me the timestamp one month from now. I found the first saturday of that month. This was in a loop so it would do +2 months then +3 months and then so on.

It worked just fine until... yesterday! August 31st. Because one month after August 31st? Puts you in October! And two months from that is ALSO october... it was repeating even months and skipping the odd months.

It sucks to have a script that works one day, and then surprise one day it DOESN'T and you didn't change anything, you're like "I've been hacked!" but no... I haven't, I just don't think ahead all that well.

And to further my laziness I didn't even change my algorithm... just put in a trap that says if today is the 31st day of the month, tell me +1 months from yesterday.