A Better Way to Display the Current Year in Your Copyright Notice

It’s New Year’s Eve and website owners everywhere will be calling up their developers asking them to update the copyright year on all of their websites. It’s your job to update the copyright notice but this is the year you finally realize that simply displaying the current year isn’t enough. You need to show the year the site was created up to the current year (e.g. “2001 – 2015”). On top of that, you’ve got a mix of static HTML and dynamic PHP pages. How does one dynamically generate a copyright notice on a static page? Easy: JavaScript with a fallback or PHP depending on your stack. If you use any other language the code will be roughly the same with some syntax differences thrown in.

What is this “better” way?

Most sites running PHP will slap a quick Copyright &copy; <?php echo date('Y'); ?> Acme Co. in their footer and call it a day. But a lot of visitors have become savvy to that and know that its a trick being played by a computer. You may ask why the copyright year even matters. Well, it may be surprising to find out that many visitors judge your trustworthiness by the age of your website. By slapping the current year in the copyright portion of the site footer you’re telling visitors that you’re either a brand new site or are just putting that there for the sake of putting it there.

Do you even know why you’re putting that copyright statement on your site? It seems like a lot of website owners just do it because they’ve seen if before. If you’re going to use any of these techniques for your own site, please try to have a reason for adding a copyright statement in your footer. Don’t just do it because you’ve seen it before. For me, my reasons are as follows:

  • Show visitors how long the site has been running – regardless of how many times I redesign a site, I’ll always use the original publishing year in my copyright notice.
  • Establish who owns the content of the website – Technically, you don’t need to put a copyright notice on your website to be granted a copyright. The act of creating and publishing it grants you a copyright automatically (since 1989). That said, by providing the copyright statement on your website you are explicitly letting the world know who is the creator of that work and when the work was originally published. Copyright grants you the right to set the rules for how your content is consumed. Even free and open source works can – and technically are – copyrighted by their creators. If you create an open source project the copyright allows you to say “hey, I made this and I’m giving it away under the MIT or GPL or whatever license but I reserve the right to stop doing that at any point”. I use the copyright statement to take ownership of my work. I want people to know who the person who created it was.

Fun fact: Although you are automatically granted a copyright whenever publishing an original work online, it is hard (maybe impossible) to sue for infringement of that work unless you formally register it with the US Copyright cartel (not their actual name). The problem with digital works like websites though is that even with a formally registered copyright, if you change the website the copyright only covers the version of it that you had originally registered. There’s a great Sitepoint article about website copyrights that explains this in depth.

How it works/What will users see?

Whether you run a static or dynamic site, this method of displaying the copyright will show the correct span of years the site has been operating. It’ll even cover the case where the site is brand new and you only need to display the current year.

For example, if you launched the site in 2005 then this code will show “Copyright 2005 – 2015 Acme Co.”. If your site is brand new and you want to make sure that the copyright not only stays up to date but shows just the current year but not need to update the site later on, then this method will also work. For example, if you publish a site on December 31st, 2014 then for the rest of that day your notice will display “Copyright 2014 Acme Co.” but as soon as the clock strikes midnight on January 1st, your site will automatically display “Copyright 2014 – 2015 Acme Co.”.

Method 1: PHP

You can add this code to your framework as a helper function or hard code it into your template. How you do this really depends on your project and there is no right way, only the way that’s right for you.

1
2
3
4
5
6
7
8
9
10
<?php
  $start_year = '2014';    // Date your site was created
  $curr_year  = date('Y'); // The current year

  // A one-liner to determine if the copyright is a single year or a range
  $copyright = ($curr_year > $start_year) ? $start_year . '-' . $curr_year : $start_year;
?>
<footer>
  Copyright &copy; <?php echo $copyright; ?> Acme Co.
</footer>

The code above sets up your initial publication year and will check if the current year is greater than it. If it is then the copyright notice becomes a range. If it isn’t then you only get a single year. The $copyright = ... statement is a ternary statement. You probably already knew that but if not, a ternary statement lets you do simple if/else comparisons in one line. They exist in just about every language and usually use the same syntax. That line is the same as writing this:

1
2
3
4
5
6
7
8
<?php
  if ($curr_year > $start_year) {
    $copyright = $start_year . '-' . $curr_year;
  }
  else {
    $copyright = $start_year;
  }
?>

Why write 6 lines of code when one will do?

Method 2: JavaScript

If you have a static site with no server side rendering then this method will work the same way except on the client. We do use jQuery here but you can just as easily use vanilla JS.

1
2
3
4
5
6
7
8
9
<footer>
  Copyright &copy; <span id="copyright">2014</span> Acme Co.
</footer>
<script>
  var thisYear  = new Date().getFullYear(),
      startYear = '2014';

  if (thisYear > startYear) { $('#copyright').text(startYear + '-' + thisYear); }
</script>

What we’ve done here is the same as the PHP script with a twist. We store the original copyright year and the current year in variables then we check to see if the current year is greater than the original start year. Here’s the twist: we don’t use an else or ternary statement in this code. Instead, if the condition is true we replace the text of the #copyright span with our date range. If it’s false then we keep the text that’s already in there.

The additional benefit to this is that it will work for users who don’t have JavaScript enabled. For those few users, rather than seeing no year at all, they’ll see the original publishing year. After all, it’s better to show a date in the past rather than the current year. Some may argue that having the current year in the footer gives the impression that the content is fresh. Yes, it does. But it also doesn’t give any clue as to how long you’ve been running the site and doesn’t give additional trust signals like a range does.

Conclusion

I would rather have a copyright year in the past as a fallback like the JS shown above rather than always having the current year and giving users no indication of how long you’ve been running a site (trustworthiness and authority). Having a past year in your copyright notice for those 5 people who visit your site without JavaScript enabled is trivial. If you’re worried about that then you can always use the trusty old Find and Replace method but then you’re back to square one editing your copyright notice from scratch again.

Web development

« What's the difference between jQuery's document.ready() and window.load()? Web Design is Neither a Career Path or Business »

Comments