PHP: Automatic Copyright Year

Posted by on September 10, 2013 • Filed Under Tutorials

In website footers, we usually use some kind of copyright notice. Something like: “© 2013 NicoleJeanette.me”. In some cases, it may be tedious or we may forget to update this information, especially when updating website designs. The following snippets will help you have a more automatic function of displaying the year.

Add the snippets to the file where you have your copyright notice, it’s usually in footer.php.

If you want to show the current year only:

If you want to show the starting year to the current year:

There’s a function (that validates the information) that you can use to achieve the same information above:

Using the function:

It would display as: © 2013.

It would display as: © 2010 – 2013

Hope these snippets are useful, if you have questions, don’t hesitate to leave a comment or contact me and I’ll get back to you as soon as I can!



5 Comments


  • avatar image

    Whitters

    Sep 10, 2013

    Reply

    I've always meant to do this on my blogs and then always end up forgetting when I actually code the layouts. Then I'm too lazy to go back in and fix it...

    • avatar image

      Nicole

      Sep 11, 2013

      Reply

      Yeah, it happens to me sometimes. Now, one of the first things I code on new themes is the copyright notice because if I don't I'll probably forget to add it after the theme is done.

  • avatar image

    Breia Brickey

    Sep 11, 2013

    Reply

    You make this look so easy, but when I think of doing this kind of stuff myself, I freak out. Thanks for the easy to follow tutorials that you post.

    • avatar image

      Nicole

      Sep 11, 2013

      Reply

      You're welcome! I'm glad you liked it, I never know if they're clear enough for people to understand. Feel free to contact me if you have any questions Breia :)

  • avatar image

    adAstra

    Oct 03, 2013

    Reply

    Code is so pretty! I'm with Breia, this is way over my head.... for now! I'll just have to use you as my inspiration :D

Post your comments