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.
15 added so far, add yours!
  1. Genius! Thank you…

  2. Richard says:

    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!

  3. Eric B. says:

    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?

  4. Elena says:

    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?

  5. HrvojeKC says:

    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

  6. brianyerkes says:

    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!

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

  8. Thanks for that, was really useful!

  9. webb says:

    Thanks. works fine for me.

  10. Thanks, I was just wondering about that a few days ago!

  11. chuck says:

    shorten to:

  12. chuck says:

    oh well, nm – can’t post code here apparently

  13. ThomasR says:

    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’) ?>

  14. Thanks for the nice post – straight to the point – just how I like it :)

  15. Michele says:

    great post, beautiful website.

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