Dynamically Add a Copyright Year to a Website

Keith Curreri - Blog Headshot

By Keith Curreri on February 02, 2011

Most websites need copyright information in the footer. Usually the current year is included in the copyright info. You can code in the year by hand, but if you want the website to stay current, you will have to go back change the year every January for the rest of the website’s life.

An easier way to have a current year in the footer is to use PHP to grab the current year and display it. This way the year will always update itself and keep your website up to date.

How to add the year

Adding a year using PHP is very simple. Just add the following line of code where you would like to insert the year:

<?php echo date(Y); ?>

Make sure that your website file is saved as a .php file and not an .html one. Save the file and refresh your browser and relax knowing that you won’t have to keep updating the year on the website!

Did you like this post? Want to get more like it?

Website Redesign Course
Subscribe
Notify of
guest
5 Comments
Inline Feedbacks
View all comments
trackback

[…] have you ever wanted to add the year of copyright to your blog? My friend Keith wrote a post titled Dynamically Add A Copyright Year To A Website. Basically there’s this bit of code you add to your footer and viola, somehow it knows what […]

Mitch
12 years ago

Wait… I’m confused. I see the code I’m supposed to put into my footer, but what PHP file am I creating and what am I putting in there?

Keith
Keith
12 years ago
Reply to  Mitch

Hi Mitch,

You’re not necessarily creating a new file, you just need to find where the footer information is and add the above line of php. If you are using WordPress, the footer info would be in your theme’s footer.php file.

I may have worded my post confusingly. I mention saving the file as a .php file because the php code will not work in an .html page. Since WordPress is already configured for php, it should work fine.

Mitch
12 years ago
Reply to  Keith

Okay, I got it this time around. Popped it in and it worked; then made modifications to it and I’m still a happy guy. Thanks!

Keith
Keith
12 years ago
Reply to  Mitch

Great, glad to hear it!

5
0
Would love your thoughts, please comment.x
()
x