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.
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!
[…] 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 […]
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?
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.
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!
Great, glad to hear it!