Javascript: Creating a dynamic Copyright footer


Copyright Image

Updating your website's copyright year on annual basis can be annoying, to make your copyright year dynamically change, simply use the new Date.getFullYear(); code as shown in the example below.

Live Demo at CodePen


the HTML:
&copy; 1997 - <span id="currentYear"></span>
// desired ouput: © 1997 - 2017

on pure Javascript:
document.getElementById('currentYear').innerHTML = new Date().getFullYear();

or if you use jQuery [CodePen demo]:
$('#currentYear').html(new Date().getFullYear());

Comments