Automatically Update Your Copyright Year with PHP

Published Jan 25, 2017Last updated Jan 31, 2017
Automatically Update Your Copyright Year with PHP

This tutorial is written for those of you who find yourself forgetting to update the year in your site's copyright line. I've seen some sites with copyright lines that are over five years outdated. Let's take a look at how you can set your site's footer to always display the current year in the copyright line.

In most cases, you will find this in your theme's footer.php file. If you are using a child theme (you should be), you will first want to look for the footer.php file within your child theme's directory.

In the most recent WordPress default Twenty Seventeen theme, you will be editing /template-parts/footer/site-info.php.

copyright date

Once you have identified the proper file to edit, open it and look for the text from your footer's copyright line. In Twenty Seventeen as well as many other themes, this is found within a div with the class "site-info".

copyright date

Now that we know where to make the changes, let's update it to display a dynamic copyright line.

To get the current year in PHP we can use:

echo date("Y");

Keep in mind that this returns the date from the server.

How to display the current year using PHP

Now you can get back to focusing on celebrating the new year instead of worrying about your copyright date!
No more updates needed — your footer copyright will always display the current year!

Discover and read more posts from Hosea Baker - Creative Problem Solver
get started