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!
-
Genius! Thank you…
-
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
echoor 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, 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 for that, was really useful!
-
Thanks. works fine for me.
-
Thanks, I was just wondering about that a few days ago!
-
shorten to:
-
oh well, nm – can’t post code here apparently
-
Many persons make a mistac while adding copyright to their sites.
A copyright starts at a year and ends at another.
You should have written :
Copyright 2009 – <?php echo date(‘Y’) ?>
-
Thanks for the nice post – straight to the point – just how I like it
-
great post, beautiful website.


