Display Current Year With PHP
posted in PHP Tutorials, Productivity, Web Design, Web Design Resources, Wordpress
Now that 2010 is just starting, many web designers have to update the copyright year on their own websites, and their client’s websites.
Many end up doing it manually and waste a lot of time with this tedious task, but some use a better method, and it’s as simple as one line of PHP.
Copyright <? print(Date("Y")); ?>
No longer do you have to manually edit the footer of your websites with each year that passes!
Just a little thing to add. I use something like this:
© Richard Vanbergen (& copy; remove space.)
Then you get a nice little copyright symbol too!
I currently use this on every website that I create. It is a useful technique.
Do you know if it would be better to use echo or print?
I never knew it could be so easy. Thanks for this. One question though, does it have to be a Wordpress website or can it be any type of website?
echo should be faster than print by some benchmarks but it’s not important for this kind of displaying data.
Sometimes the date(‘Y’) does not display the year then you could use date(‘o’)
Details can be found on the following address http://php.net/manual/en/function.date.php
Thanks everyone for your comments and glad some of you found it helpful.
Elena, it can be used on any page of a website that is in PHP. It is a basic PHP call.
HrvojeKC, thanks for your additional comments!
Thanks, Brian! This is EXACTLY what I need–didn’t know about PHP last year and I’m tired of trying to keep up all the sites manually.
Thanks, I was just wondering about that a few days ago!
shorten to:
oh well, nm – can’t post code here apparently


