Hello my friend. Welcome back! In this tutorial you’ll learn how to add a dynamic copyright year with JavaScript. Now, imagine this case. It’s New Year’s EVE and you start thinking – I need to manually change all the copyright info on my client’s websites to match this new year…

But, if you add a little HTML and JavaScript code you don’t even need to worry about this again.

What do you rather see in a website? Copyright © 2017 YouDivi or Copyright © 2017 – 2019 YouDivi?

So, if you want to add this neat feature to your WordPress website just follow this quick tutorial.

It took me some time to find this answer on the internet. I’m grateful for Martin Adams who posted the answer in a Stack Overflow page.

Update: This tutorial at updateyourfooter.com helps to understand how to change your static timestamp to an automatically updating copyright year.

Without further ado, let’s start!

How to add a dynamic copyright year with JavaScript


First of all, go to Appearance > Widgets and add a Text Module.

Then, select the Text way of writing – Visual doesn’t work for plain HTML code – and add the following JavaScript code.

Add a dynamic copyright year with JavaScript image

<p>© Copyright 2017 <script>new Date().getFullYear()>2017&&document.write("- "+new Date().getFullYear());</script> Company Name – All rights reserved.</p>

Important: change both numbers to match the year that you started developing the website. The JavaScript will automatically fetch the current year and add it after the older year date.

You may run tests to see how it works. Change both years to 2014 for example and see what happens. It’ll print 2014 – current year.

If you’re interested in learning how to add your logo to your WordPress footer click here.


So, did you already add a dynamic copyright year with JavaScript to your WordPress website?

I hope you learned a thing or two from this blog post. Please, subscribe for more tutorials soon.

See ya!