Getting the copyright date right

php logo

Lots of websites show a copyright notice in the page footer with an incorrect copyright date – last year or the year before, for example. Or maybe they just show the current year using php or JavaScript.

Our website shows “© 2011 – [current_year]”. Why would we want to do that? Well, it lets our visitors know that we’ve not just sprung up overnight, but have been around for a few years.

Here’s a quick php snippet to achieve just that.

How it works

First, change the $first_year variable to the year your site was created. The script will compare $first_year with the current year (from php’s date() function) and if they are the same, it will display only the current year. If $first_year is in the past, the script will display a range of years – $first_year to the current year.

To display the copyright notice, use the following code in the footer of the site: