Web Analytics Made Easy -
StatCounter Anyone auto date change code? - CodingForum

Announcement

Collapse
No announcement yet.

Anyone auto date change code?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyone auto date change code?

    I have a date that needs to stay static for one week at a time. Like: "offer ends 5/19/04". Anyone know code that will make that auto change every week to the following week. 5/26/04, 6/2/04 etc.

    Thanks in advance.

  • #2
    Maybe this?
    Code:
    <script language="JavaScript">
    function addDays(myDate,days) {
        return new Date(myDate.getTime() + days*24*60*60*1000);
    }
    
    document.write(addDays(new Date(),7));
    </script>
    This adds 7 days onto today's date. Or should do

    Comment


    • #3
      Works great! Thanks for your help.

      Comment


      • #4
        With javascript if the users computers time is off then so will the time on your site. How about php instead? The server time is probally more reliable.

        Below is my php footer on my site. The 2001 always stays the same but the echo date line changes with the year.

        PHP Code:
        <?php
            
        echo '© 2001-';
            echo 
        date('Y');
            echo 
        ' Leonard Whistler';
            echo 
        '<br>email:  [email][email protected][/email]';
        ?>
        Leonard Whistler
        Leonard Whistler

        Comment


        • #5
          does anyone know how to make this work on a daily basis auto changing at 3pm and skipping sunday?

          Bit of a challenge.. In case I havnt explained it properly we run a site that shows the next day delivery date. if an order is placed after 3 it wont get there next day..

          Thanks

          Comment

          Working...
          X