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…

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

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

MODx
I use a snippet called CurrentYear:

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

if you liked this post :)

Category: Programming | 447 views | Posted: January 11th 2008 10:33 am

Related Posts

2 Comments »

MyAvatars 0.2

Comment by Jalaj
on 14 Jan 2008 at 6:43 am # Subscribed to comments via email

But displaying the latest year with copyright goes against us that that it misinforms the actual year when development actually started.

 
MyAvatars 0.2

Comment by James Ehly
on 14 Jan 2008 at 8:58 am #

I agree with you Jalaj, and will probably change the code in the example to have a date span. It’s easy enough to place a beginning date along with the current date and for most websites that would be correct since they are updated frequently. I’ve found that for some reason with websites, it’s a big deal to have the date be current (even if content hasn’t changed). That is what a lot of my clients want, because they think it makes the site look up to date. I think that a date span shows longevity as well as ‘currentness’. Thanks for your comment :)

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

« HTML2PS and HTML2PDF - Best HTML to PDF Converter | New Tool - CSS Formatter and Optimizer »