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

  16. J. Hendrix says:

    Just what I needed, thanks!

  17. Thank you for this nice little code. Appreciate it. :)

  18. Hi just wanted to give you a quick heads up and let you know a few of the images aren’t loading properly. I’m not sure why but I think its a linking issue. I’ve tried it in two different browsers and both show the same outcome.

  19. fax server says:

    In the great pattern of things you’ll get a B- just for hard work. Exactly where you actually misplaced me personally was in the particulars. As they say, the devil is in the details… And it could not be more accurate here. Having said that, permit me say to you what did do the job. The writing can be quite convincing and that is probably the reason why I am taking the effort in order to comment. I do not make it a regular habit of doing that. 2nd, although I can certainly see the jumps in reasoning you come up with, I am not confident of just how you seem to connect the ideas that produce your conclusion. For the moment I shall yield to your position but wish in the near future you link your dots better.