1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript Auto Update Year in Footer

Discussion in 'Web Development' started by ishkey, Apr 1, 2012.

  1. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    Here is a little JavaScript which will update the year in your footer next to your Company copyright.
    This way you never have to remember to go back at the first of the year and change all your pages.

    This first one shows the current year.
    compnameyear1.jpg
    HTML:
      <script type="text/javascript">
            var d = new Date();
            document.write('<span class="copyright">© ' + d.getFullYear() + ' Your CompanyName</span>');
            </script>

    This second one is for those who like to display their start date along with the current year.
    compnameyear2.jpg
    HTML:
    <script type="text/javascript">
            var d = new Date();
            document.write('<span class="copyright">© Your CompanyName 1993 - ' + d.getFullYear() + ' </span>');
            </script>

    Shown here is how I used it in a website.
    On either side is a clickable link.
    compnameyear.jpg
    HTML:
    <div class="subfooter">
                    <p><a href="sitemap.html"><span>sitemap</span></a><script type="text/javascript">
            var d = new Date();
            document.write('<span class="copyright">©  ' + d.getFullYear() + ' Your CompanyName</span>');
            </script>
                      <a href="terms_privacy.html"><span>Terms | Privacy</span></a></p>
            </div>