Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding Dates - strtotime + date confusion ... help ...

    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.

    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

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Look at this link, 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).

  • #3
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Fumigator,
    Looks like a brain cruncher, I'll go through and see what I can do.

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

    Best Regards,
    Paul

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Everyone,
    Found the solution. How strange, someone was looking down from above, as I found the solution here - 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.

    Regards,
    Paul


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •