Results 1 to 2 of 2

Thread: X number of days ago script

  1. #1
    Join Date
    Sep 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default X number of days ago script

    I need something that will display a date that is 30 days ago from today as well as another date that is 60 days ago. Including weekends.

    I have been searching everywhere and cant find something like this. Anyone know code for it?

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sure, try something like the below script:

    Code:
    <script type="text/javascript">
    
    function displaybackday(offset){
    var pastdate=new Date()
    pastdate.setDate(new Date().getDate()+offset)
    document.write('<p>'+pastdate.toLocaleString()+'</p>')
    }
    
    displaybackday(-30) //display date/ time -30 days from today
    
    displaybackday(-60) //display date/ time -30 days from today
    
    </script>

Bookmarks

Posting Permissions

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