Automation Tip: How To Auto Set Copyright Years*

Now that it's January 2008 some of my clients are noticing that the year in their copyright statements don't reflect 2008. Now, I always set this to drop in a dynamic value, but that wasn't the case before I was hired. This is such an easy thing to set up when you are developing a site so I suggest you do it right from the start. I use 3 main types of copyright year automation...

y = new Date();
year = y.getFullYear();
CopyrightLine = " <p>Copyright &copy; 2001-"+year+" Company Name - All Rights Reserved.</p>";

<p>Copyright &copy; 2005-<?=date('Y')?> Company Name - All Rights Reserved.</p>

I use a snippet called CurrentYear:

print date('Y');

In the template place this:

<p>Copyright &copy; [[CurrentYear]] Company Name - All Rights Reserved.</p>

*I know this is a really easy and obvious thing to do, but I wanted to post it for 2 reasons:

  1. Sometimes the easy and obvious things are easily missed - especially in programming.
  2. Automation is one of the keys to being successful as a web developer/programmer. It's possible to automate every step in the web development process and there are some who have claimed to do so. I've automated a lot of the CMS setup for MODx (here and here), as well as auto writing CRUD for CodeIgniter. Any time I'm creating a process or workflow, I try to program a way to automate it. This post is just a tiny example of that.

This post was edited to reflect date spans, which I think is the best way to show copyright years. This way it shows longevity of the site, keeps the site looking current, and tells the users what years content was created in.