PHP Date Question??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FADE19
    Snow's Parole Officer
    • Sep 2001
    • 1161

    #1

    PHP Date Question??

    Alright I was wondering if any of ya folks had a script lying around that would tell me "when the next friday is:"

    Mon = Jan 1, 2001
    the code would print out
    Jan 5, 2001

    if the day was Jan Sun 10, 2001
    it would look ahead to the next friday.
    Jan 15, 2001

    or if it was friday it just prints the current friday's date..

    any info would be greatly appreciated...thanks
  • JackFoley
    Confirmed User
    • Jul 2001
    • 858

    #2
    I use this on one of my sites for weekly updates. It might not be the most efficient way, but it works.

    <?php
    $day = date("d");
    $month = date("m");
    $year = date("Y");
    $next = date("F jS, Y", mktime(0,0,0,$month,$day+5-date("w",mktime(0,0,0,$month,$day,$year)),$year));
    echo("Next set will be added $next.");
    ?>

    Ack. Make sure the $next line doesn't wrap (it should all be on one line).

    ------------------
    SlutBunnies - $30/sale, bitch.

    [This message has been edited by JackFoley (edited 12-02-2001).]
    SUBMIT | TRADE | CONTACT

    Comment

    • Theo
      HAL 9000
      • May 2001
      • 34515

      #3
      echo gmDate("m j Y");
      this will print today

      echo gmDate("m j Y",time() - 86400);
      this wil print yesterday

      multiply 86400 x the no of days you want, In your case is 5. So you'll put
      echo gmDate("m j Y",time() - 432000);


      Comment

      • Theo
        HAL 9000
        • May 2001
        • 34515

        #4
        my script prints the date in the following format:
        12 2 2001
        wait a min to see how it will go in your case

        Comment

        • Theo
          HAL 9000
          • May 2001
          • 34515

          #5
          echo gmDate("M d Y",time() - 432000);

          i think that's the case

          Comment

          • FADE19
            Snow's Parole Officer
            • Sep 2001
            • 1161

            #6
            Thanks guys...I got it...LOL, it came to me after I posted the question...isn't that always the case

            Comment

            Working...