
Although we’re less interested in the actual copyright for a website, correctly setting the copyright year in the footer of a web page/site is something that us web developers and webmasters are keen to do every 1st of January.
However, if you have a PHP-based website (such as WordPress), then here’s a simple bit of code you can copy-n-paste to always have the right date in your website footer.
A website started before this year
If your website was started before the current year (e.g. 2011), then this will work perfectly. The date(“Y”) code will output the current year, so the following will show “© Copyright 2011-2012” if the current year is 2012 (which it is at the time of writing).
© Copyright 2011-<?php echo date("Y"); ?>A website started this year
If you’ve started a website this year, then you clearly don’t want to show “Copyright 2012-2012“. So that’s why you can use the code below, which will automatically include subsequent years once you move into next year (so 2013 in this case).
<?php
// Goes anywhere you like, if using WordPress, then we recommend putting it into functions.php.
function showDateRange($startYear) {
$thisYear = date("Y");
if ($startYear == $thisYear) {
return $thisYear;
}
return sprintf('%s-%s', $startYear, $thisYear);
}
?>
And this bit goes into footer.php if you’re using WordPress, or your main template if using any other PHP-based template.
© Copyright <?php echo showDateRange('2011'); ?>What you’ll get is:
- © Copyright 2011 – when you’re in 2011
- © Copyright 2011-2012 – when you’re in 2012
- © Copyright 2011-2013 – when you’re in 2013, etc
You’ll never need to update the footer copyright again! :)



