Forgot to update the year in the footer again? Fix it once and for all with this simple javascript snippet - ByteScout
  • Home
  • /
  • Blog
  • /
  • Forgot to update the year in the footer again? Fix it once and for all with this simple javascript snippet

Forgot to update the year in the footer again? Fix it once and for all with this simple javascript snippet

This article from the 2019 year was updated in January 2020 because the same issue strikes many websites in 2020 again!

updating year from 2018 to 2020 update in the footer

It is 2020 year already but many websites still have their footers saying something like “MySiteName.com (c) 2019“. Well, yes, someone was just too busy and forgot to change the footer to show 2020 instead of 2019 (or maybe even 2018).

It is 2019 year already but lot of websites still have their footers saying something like “MySiteName.com (c) 2017-2018“.

Thanks to Javascript gods, now you can easily fix it with a just one line of js code so your website visitors won’t think “gosh, are these guys still in business in 2020?”

If you use WordPress:

  1. Go to yourwebsite.com/wp-admin to open admin panel
  2. Find your theme name in the left menu (Avada, Jupiter or any other that you have on your website)
  3. Open it and find “Footer” option
  4. Footer content editor will open, switch to Text mode

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-2019 MyWebSite.com — All Rights Reserved

Replace it with the following html and javascript snippet where 2019 is replaced with javascript snippet using 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 shows the current year.

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.

   

About the Author

ByteScout Team ByteScout Team of Writers ByteScout has a team of professional writers proficient in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.  
prev
next