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
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Finding a floating date with PHP

    I'm trying to find a floating date (for lack of a better word) like Thanksgiving with PHP. However, turns out that strtotime doesn't like the idea of turning "third Thursday in November" in a UNIX timestamp.

    Is there any way to retrieve a floating date like this?

  • #2
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    strtotime seems to actually like something similar to what you tried, surprisingly enough. Try something like:

    PHP Code:
    echo date('F j, Y'strtotime('November 1 next Thursday +2 weeks')); 
    I had no idea it was so robust.

    e: maybe you want Oct 31 next Thursday instead, I don't know, it's confusing me :/

  • #3
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hmmm...I tried typing in Thanksgiving to see if that'd work, but that didn't. The October one works, kind of. The day is off by three.

    This is kind of annoying. I can find a formula for Easter, but Thanksgiving/Mother's Day/Father's Day? Out of the question.

  • #4
    New Coder
    Join Date
    Dec 2004
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This page is chock full of such dates.
    http://us3.php.net/strtotime

    -Bill

  • #5
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hmmm, why didn't I see that before. Thanks, it helps alot. o.o

    Edit: The comment about the dates, not the page for strtotime.


  •  

    Posting Permissions

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