This article was updated on January 8, 2021. Initially published on January 14, 2019
It is this time of the year. I mean it is 2020 2021 already but many websites still have their footers showing previous year, like this “MySiteName.com (c) 2018-2020“. Someone was too busy and forgot to change the footer for 2021.
Thanks to the Gods of Javascript and browsers, you can easily fix it with just one line of Javascript code once and for all. your website visitors won’t think “gosh, are these guys still in business in 2020?”
If you use WordPress:
If you use another website management system then simply find a place in the code which is used for a footer.
Your current footer probably looks like this:
© Copyright 2010-2020 MyWebSite.com — All Rights Reserved
Replace it with the following html and a small JavaScript code where 2020 is replaced with JavaScript snippet automatically showing the current year.
© Copyright 2010- <span id='footer-copyright'></span> <script> document.getElementById('footer-copyright'). appendChild(document.createTextNode( new Date().getFullYear())); </script> MyWebSite.com — All Rights Reserved
Save your footer and open your website. You will see that now it automatically shows the current year (and will adjust it automatically):
© Copyright 2010-2021 MyWebSite.com — All Rights Reserved
How it works?
Every time a visitor opens your website in a browser, this JavaScript snippet reads a current year from the browser and shows it to a viewer! You may relax next January because the copyright year in the footer will change for visitors to your website automatically.
Troubleshooting:
I’m using WordPress and I see some strange symbols instead of the year.
Solution:
Probably you forgot to switch to Text mode when you were editing Footer. Try again and update the footer in Text mode, save and check again.