Although there is a substantial movement for alternative usage guidelines (Copyleft, Creative Commons, etc) I haven’t found a client yet that wasn’t just a little concerned about commercial usage rights.  Given that, however, a quick tour around will find many business sites with outdated copyright dates on them.  So here are three snippets of code I use to keep copyright dates up-to-date on sites without having to manually update them every year.

JavaScript

This first method uses JavaScript and can be incorporated into nearly any page. Yes, if a user has JavaScript turned off, this process will be degraded. You may want to include the <noscript> tag if you think this may be a common occurrence on your site.

This part goes in the HEAD of your document (or an externally referenced JavaScript file, if you prefer):


<script type="text/javascript">
current=new Date();
year=current.getFullYear();
</script>

This part is placed wherever you want your copyright text to appear. You can modify it with CSS as you please.


&copy; Copyright 2004 - <script type="text/javascript">
document.write(year);
</script>

PHP Method

If your site/page supports PHP you can use the following method. Its a bit more reliable than the JavaScript method.  Its also useful for WordPress templates (which, for some reason, is often missing). You can usually find it in the footer.php of most templates.


&copy; Copyright 2004 - <?php echo date('Y'); ?>