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
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 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
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Feb 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Works great! Thanks for your help.

  • #4
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    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]len_whistler@yahoo.com[/email]';
    ?>
    Leonard Whistler
    http://www.stubby.ca
    Leonard Whistler

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

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