Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2003
    Location
    eastern USA
    Posts
    541

    generate date link in PHP

    Every Thursday, a website I link to creates a new webpage of discounts. For example, today is Thursday June 23, so the filename is 2005-06-23.html.

    What I want to do is to change the link on my page to automatically update when it is Thursday so that it is <a href="http://www.otherwebsite.com/discounts/2005-06-23.html">link</a>
    and next Thursday it would be
    <a href="http://www.otherwebsite.com/discounts/2005-06-30.html">link</a>
    and so forth.

    I hope I am explaining it clearly.

    What would be a good way of doing this in PHP?

  2. #2
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    1,082

  3. #3
    Join Date
    Mar 2003
    Location
    eastern USA
    Posts
    541
    thanks
    but the link should not be of the current date
    which is what I think your example does

    the link should change every Thursday but stay unchanged
    until the next Thursday

  4. #4
    change error404's code a bit
    PHP Code:
    date('Y-m-d',strtotime('last Thursday',strtotime('+1 day'))); 

  5. #5
    Join Date
    Mar 2003
    Location
    eastern USA
    Posts
    541

    Thumbs up

    Coderdan,


    Thanks!

    In your code if it isn't a Thursday then you get the timestamp of the previous Thursday.

    But I'm not sure how it is adjusting so that if it is a Thursday
    then you just get the timestamp.

    I'm a beginner with PHP.

  6. #6
    That is why a day is added first. It has no influence on the result except if the day is Thursday.

  7. #7
    Join Date
    Mar 2003
    Location
    eastern USA
    Posts
    541

    Smile

    ingenious!

    there I was going through all sorts of gyrations, and it was that simple.

    thanks again.

Posting Permissions

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