Skip to content

Instantly share code, notes, and snippets.

@dlucero23
Last active August 18, 2017 22:56
Show Gist options
  • Save dlucero23/35011481544994753807d8916f2a294a to your computer and use it in GitHub Desktop.
Save dlucero23/35011481544994753807d8916f2a294a to your computer and use it in GitHub Desktop.
Auto Updating Copyright Year JS Script. Great for including in footers
<p>©2012<span id="autodate"></span> Siam Tek is a Trademark of Siam Tek Web Design Group, LLC, <br>POWERED BY <a href="//siamtek.com/solutions" title="Siam Tek Web Design Group - Digital Marketing for Online Businesses">Siam Tek - Tampa Bay Digital Marketing.</a></p>
// Create a new function called newDate()
function newDate() {
//return a new Date() -- returns the current calendar year.
return new Date().getFullYear();
}
// after everything else has loaded on the page, load this command: find the element (like a <span>) with the ID of 'autoupdate' and insert the dash '-' and the result of the newDate() function that returns the current calendar year. (ie. '-2017' or whatever the current calendar year is)
document.onload = document.getElementById("autodate").innerHTML = '-' + newDate();
@dlucero23
Copy link
Author

Everything is explained in the js comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment