New Webmasters > Automatically Update Your Year With PHP

Automatically Update Your Year With PHP

Since we are at the start of a new year, many people will be updating their website footers to correct the current year in their copyright notice. Here is a quick tip for those of you using PHP who wish to update the year automatically. You can use this tip with WordPress since it is PHP-powered.

Use this php code below in your footer to print a copyright notice for the current year.

This website &copy; <?php echo date("Y"); ?>

This will print out something like this:

This website © 2009

A lot of people (myself included) like to add the first year that a page was published to their copyright notice. You can hard code the starting year and get PHP to dynamically update the current year. Modify this code to suit your needs:

This website &copy; 2005 - <?php echo date("Y"); ?>

Your copyright footer will now look something like this:

This website © 2005 - 2009

Hope you find this tip useful.

Share this page with others
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Furl
  • Reddit
  • blogmarks
  • Propeller

Most Commented Posts

Discussion

One comment for “Automatically Update Your Year With PHP”

  1. Smack-dab what I was lonoikg for-ty!

    Posted by Prudy | July 20, 2011, 1:18 pm

Post a comment