42 users online (1 members and 41 guests)  


  Results 1 to 7 of 7

Related

  1. Adding a date    Forum: Website Scripts Forum
    Replies: 1
  2. Getting todays date with javascript    Forum: Javascript Forum
    Replies: 3
  3. order by date    Forum: PHP Forum
    Replies: 10
  4. Java Date    Forum: Javascript Forum
    Replies: 3
  5. Date Validation    Forum: HTML Forum
    Replies: 7
  1. #1
    rmcelwee's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2006
    Posts
    4

    yesterday's date in a link?

    I have read the thread showing how to display todays date ( http://www.ahfb2000.com/webmaster_he...read.php?t=556 )but what I am looking for is a little bit different. How do I add yesterdays date to a link (like below):
    <a href="http://mytext.com/11052006.txt"> click here to download yesterday's text</a><br>
    I would put 3 days on there - today, yesterday, and day before yesterday and have it update every day.

    Thanks!!!

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: yesterday's date in a link?

    try this:

    Code:
    var futdate = new Date()
    var expdate = futdate.getTime()
    expdate -= 86400*1000 //expires in 1 hour(milliseconds) 
    //alert(expdate);
    futdate.setTime(expdate)
    alert(futdate);

  3. #3
    rmcelwee's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2006
    Posts
    4

    Re: yesterday's date in a link?

    Quote Originally Posted by ALL
    try this:
    That displays the time in a pop up box, but does not display it as a link (for clicking on it and downloading as in my example). Thanks for trying though!

  4. #4
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: yesterday's date in a link?

    oh well i figured you knew javascript a little...

    then try this:
    Code:
    var expdate = futdate.getTime()
    expdate -= 86400*1000 //expires in 1 hour(milliseconds) 
    //alert(expdate);
    futdate.setTime(expdate)
    //alert(futdate);
    
    var a = document.createElement('a');
    a.href = "http://www.google.com/"+futdate;
    a.title = futdate;
    a.innerHTML ="CLICK HERE!";
    document.getElementsByTagName('body')[0].appendChild(a);

  5. #5
    rmcelwee's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2006
    Posts
    4

    Re: yesterday's date in a link?

    I added the text below to my html and it doesn't do anything (nothing shows up on the page):



    <script language="JavaScript">
    var expdate = futdate.getTime()
    expdate -= 86400*1000 //expires in 1 hour(milliseconds)
    //alert(expdate);
    futdate.setTime(expdate)
    //alert(futdate);
    var a = document.createElement('a');
    a.href = "<A href="http://www.google.com/"+futdate">http://www.google.com/"+futdate;
    a.title = futdate;
    a.innerHTML ="CLICK HERE!";
    document.getElementsByTagName('body')[0].appendChild(a);
    </script>

  6. #6
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: yesterday's date in a link?

    Quote Originally Posted by rmcelwee
    I added the text below to my html and it doesn't do anything (nothing shows up on the page):



    <script language="JavaScript">
    var expdate = futdate.getTime()
    expdate -= 86400*1000 //expires in 1 hour(milliseconds)
    //alert(expdate);
    futdate.setTime(expdate)
    //alert(futdate);
    var a = document.createElement('a');
    a.href = "<A href="http://www.google.com/"+futdate">http://www.google.com/"+futdate;
    a.title = futdate;
    a.innerHTML ="CLICK HERE!";
    document.getElementsByTagName('body')[0].appendChild(a);
    </script>
    well first off you have a few errors in your code...

    second off... i missed the first line of code (probably when i copied and pasted it).

    here is the code this time...

    HTML Code:
    <html>
    
    <head>
    </head>
    
    <body>
    <script language="JavaScript">
    var futdate = new Date()
    var expdate = futdate.getTime()
    expdate -= 86400*1000 //expires in 1 hour(milliseconds) 
    //alert(expdate);
    futdate.setTime(expdate)
    //alert(futdate);
    var a = document.createElement('a');
    a.href = 'http://www.google.com/'+futdate;
    a.title = futdate;
    a.innerHTML ="CLICK HERE!";
    document.getElementsByTagName('body')[0].appendChild(a);
    </script>
    </body>
    
    </html>
    This time i know it works! because i was just running it in IE7!

    -ALL

  7. #7
    rmcelwee's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2006
    Posts
    4

    Re: yesterday's date in a link?

    Close, but it doesn't get me in my needed format. It contains the time, day of the week, EST, and some other stuff. Thanks though, I appreciate it!
    <a href="http://mytext.com/11052006.txt"> click here to download yesterday's text</a><br>



Tags for this Thread