Display Current Year With PHP

posted in PHP Tutorials, Productivity, Web Design, Web Design Resources, Wordpress

img-phpyear

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!

Subscribe via RSS or email. You can also follow me on Twitter if you like.
12 added so far, add yours!

    Genius! Thank you…

    Richard Jan 1, 2010 at 10:36 pm

    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?

    HrvojeKC Jan 2, 2010 at 5:53 am

    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 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

Name (required) :
Email(required) :
Website:
Twitter ID: