...

View Full Version : Finding Dates - strtotime + date confusion ... help ...



atom1
11-14-2007, 09:57 PM
Hi Everyone,
I've been going mad trying to solve this problem that I know php can do.
I have the option of either PHP4 or PHP5 on the server, so whichever is best, let me know. :o

All I am trying do is this; image several groups that meeting on certain days of the month:

e.g.
- Group 1 meets on the "1 Thursday" (first Thursday, I checked that PHP can work it out somehow using this format.

- Group 2 might meeting on the "last Friday" of the month.

I have all the data in a Mysql, have read it into an array from the db no problem with php, so take it at the simplest level without the db involved.

So here's a sample list of the groups and their "day of the months":

Group1 1 Thursday
Group2 3 Tuesday
Group3 First Thursday
Group4 1 Wednesday
Group5 3 Monday
Group6 Last Monday
Group7 2 Monday
Group8 2 Friday
Group9 2 Thursday
Group10 3 Wednesday
Group11 2 Wednesday
Group12 Last Friday

Note the "last" and "first" options in there. I have followed the php syntax as far as possible.

What bit of code will allow me to just whizz through, and work out the dates accordingly ? I've been through the strtotime and date functions, but trying to work out the "1 Friday", "last Thursday" etc seems tough, phew!

If anyone can give me a great way to do it, I'll be eternally grateful. :)

Many thanks for reading everyone,

Best Regards,
Paul

Fumigator
11-14-2007, 10:45 PM
Look at this link (http://r937.com/), then follow the "sample chapter" link toward the bottom of the page under the "SQL Hacks sample chapter" heading. Read the section in that PDF; it explains how to accomplish this (and it 'aint easy).

atom1
11-15-2007, 11:17 AM
Thanks Fumigator,
Looks like a brain cruncher, I'll go through and see what I can do. :thumbsup:

I guess the strtotime and date functions can't achieve this in a similar ? :o

Best Regards,
Paul

aedrin
11-15-2007, 04:01 PM
This sounds like a fun problem to solve but I don't think I have time to do it. ;)


PHP4 or PHP5 on the server

PHP5, 4 is/will be deprecated.

atom1
11-17-2007, 02:09 PM
Hi Everyone,
Found the solution. How strange, someone was looking down from above, as I found the solution here (http://uk2.php.net/strtotime) - scroll down to the comment dated 16-Nov-2007 12:44.

Voila, thanks for looking everyone, hopefully this will help someone else that might hit the brick wall gain. :thumbsup:

Regards,
Paul



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum