Dynamic Copyright Date
The copyright date in a footer of a website is often overlooked, so a site that is updated regularly could still look unloved simply by forgetting to change that date to the current year. This could easily be solved by letting that date change automatically with a small bit of php.
<?php echo date('Y'); ?>
By adding the above code it will generate a 4 digit year automatically
example
© 2009 - <?php echo date('Y'); ?> webdesignpond.co.uk
Alternatively it could be a two digit year by changing the upper-case Y to a lower-case.
© 09 - <?php echo date('y'); ?> webdesignpond.co.uk
For more date formats that can be created using php check out the PHP: date manual
Dynamic First year
Special thanks to Scott from The Web Help Forum for the code below
© <?php ini_set('date.timezone', 'Europe/London');
$startYear = '2009'; $thisYear = date('Y'); if($startYear == $thisYear){ echo $startYear; } else { echo $startYear.' &ndash '.$thisYear; } ?>
This is a more advanced way to set the date, as it will take into account the year the website was created as well as the current year. So if the current year is still the same year that the website is created it will only show that year (e.g 2009), then any year after that it will display it as © 2009 – (current year) (e.g 2009 – 2021).


twitter
forrst
google+
Rss
12
Comments
Great tip, this will be useful, thanks Diz
A slightly more advanced version, with (c) Copyright 2008 – CURRENT YEAR can be achieved with
© YOUR NAME
lol oops. It’s stripped out the code!
It’s available over at the forum anyway
http://www.webhelpforum.co.uk/server-side-snippets/auto-update-copyright-notice/
Thanks for the link Scott
to add code in a comment you need to use [code] …which I haven’t thought to style for comments, so I will have to do that when I get home tonight :p
Ah… I was using the <code> element lol
What makes the code provided in Scotts link better than the code referenced by Dizi?
Scotts code makes the first year dynamic as well. So if the site started in 2009 all through 2009 it will just show © 2009 but then in 2010 and onwards it will show © 2009 – (current year).
There we go added it to the main post with a link to the forum, that way it is explained why it is better and gives credit
I’m always surprised at how many websites/developers don’t do this,
its such a simple step that goes a long way to building a visitors confidence in a site, its crazy not to do it!
Yup I agree Gavin, a common argument that I have read is that its not that difficult to change the date once a year, but if you do a site for someone else or manage a lot of sites, surely it is easier to do this and then not have to worry about changing the date on all the sites each year.
And as you have said it does give visitors a sense of confidence in the site.
Just noticed you’d included it in the main post pixie. Nicely done
(In fairness, I only noticed cos I’ve had about 3 dozen hits from this page in the past couple of weeks lol)
Keep up the good work pixie
Thanks Scott and Dizi I will be using this on all my sites it saves me remembering to change it every year