.HTML code for Copyright 2008 -> 2009 autochange code ?

Discussion in 'HTML & Website Design' started by NicknameJustin, Nov 6, 2008.

  1. #1
    Hello again Code Experts.

    What is the .html code to include for current year in the footer,
    that update it automatic every new year?

    Probably a messy java script that has to be inserted in the <head> + in the <body> + a separate file.js,
    or is there an easier solution, like the sister to: <?php echo date('Y'); ?>
    The long version will do good if nothing easier is available

    The .PHP version that I asked for recently is here:
    http://forums.digitalpoint.com/showthread.php?t=1077580

    Thanks in advance programmers,
    Justin
     
    NicknameJustin, Nov 6, 2008 IP
  2. jarret

    jarret Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Uhh that PHP code will automatically update with the current year. So if its 2008 it will display 2008, if its 2025 it will display 2025.

    What exactly are you trying to do?
     
    jarret, Nov 6, 2008 IP
  3. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #3
    <? echo date("Y"); ?> is the easiest way.

    It can also be done in javascript with:
    [core]
    <script type="text/javascript">today=new Date();year=today.getYear();document.write (year);</script>
    [/core]

    However, I do not see why you wont use php if your server supports that, as it will be the most crossbrowser script.
     
    elias_sorensen, Nov 6, 2008 IP
  4. myst729

    myst729 Peon

    Messages:
    289
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    <script type="text/javascript">
    <!--
    var today = new Date();
    function takeYear(theDate) {
    
    	x = theDate.getYear();
    	var y = x % 100;
    	y += (y < 38) ? 2000 : 1900;
    	return y;
    }
    document.write(takeYear(today));
    </script>
    Code (markup):
     
    myst729, Nov 6, 2008 IP
  5. myst729

    myst729 Peon

    Messages:
    289
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You missed the millennium problem and in firefox it'll be 108 now:)
     
    myst729, Nov 6, 2008 IP
  6. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #6
    Check the javascript code I wrote, that's much shorter than yours.
     
    elias_sorensen, Nov 6, 2008 IP
  7. myst729

    myst729 Peon

    Messages:
    289
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    myst729, Nov 7, 2008 IP
  8. NicknameJustin

    NicknameJustin Active Member

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #8
    Thanks for your input.
    I'm trying this now and I suppose that I paste the code in the <head>code</head>
    but what is the full code to use where it should be printed out in the footer?
    Copyright (year) Justin

    Thanks again
     
    NicknameJustin, Nov 7, 2008 IP
  9. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #9
    Hi,

    You just paste the code where it should be written on the page.
     
    elias_sorensen, Nov 7, 2008 IP
  10. NicknameJustin

    NicknameJustin Active Member

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #10
    Oh, so easy. Thanks elias_sorensen and myst729 for your efforts.
    Justin.
     
    NicknameJustin, Nov 7, 2008 IP
  11. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #11
    You're welcome :)
     
    elias_sorensen, Nov 7, 2008 IP
  12. NicknameJustin

    NicknameJustin Active Member

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #12
    Update:
    The only one that works in Internet Explorer is the one below. (Other gets the error message: Copyright Code corrupted. Insert fresh copy. )
    All 3 above codes works in Firefox.

    
    [core]
    <script type="text/javascript">today=new Date();year=today.getYear();document.write (year);</script>
    [/core]
    
    Code (markup):
     
    NicknameJustin, Nov 7, 2008 IP
  13. myst729

    myst729 Peon

    Messages:
    289
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #13
    This one works in IE, the result is "2008" right now, but in Firefox it is "108".

    This page
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GetYear</title>
    </head>
    <body>
    <script type="text/javascript">
    var today = new Date();
    function takeYear(theDate) {
    	x = theDate.getYear();
    	var y = x % 100;
    	y += (y < 38) ? 2000 : 1900;
    	return y;
    }
    document.write(takeYear(today));
    </script>
    </body>
    </html>
    Code (markup):
    got "2008" in both of them.

    Btw, I tested in IE7 and Firefox3.
    Check out the tutorial in my last post, I'm sure that'll be helpful.
     
    myst729, Nov 7, 2008 IP
  14. Rodder7

    Rodder7 Active Member

    Messages:
    451
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    88
    #14
    This is a severe nube question but javascript is greek to me. How do you change the color of the year? Wrapping it in html works in ie but not in ff.
     
    Rodder7, Nov 7, 2008 IP
  15. myst729

    myst729 Peon

    Messages:
    289
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #15
    add

    
    <style type="text/css">
    <!--
    .color {color: #******}
    -->
    </style>
    Code (markup):
    and

    <span class="color">
    <script type="text/javascript">
    ..........................................
    </script>
    </span>
    Code (markup):
     
    myst729, Nov 7, 2008 IP