Simple JQuery Copyright Year script

How many websites do you see that have a copyright line with last year in it?! It’s just a sign of a lazy web developer who can’t be bothered either to update it every year, or (much better) add a simple bit of JQuery to automatically display the current year in the copyright line!

Here’s a code snippet that I use on all my websites to do just that!

In the markup add your copyright statement like this:

&copy; My Company <span id=”year”></span>. All rights reserved.

And then add this script to your page (after your JQuery reference):

    var theYear = new Date.getFullYear();

The end result (assuming you’re reading this in 2015…) will look like this:

© My Company 2015. All rights reserved.

Tagged with: ,