Automatic Date for Footer


/ Published in: JavaScript
Save to your folder(s)

You can use this script to always keep the copyright notice on the footer of your website current. For example, instead of having to update the year at the beginning of each year, this script will display current year. I'm sure there's an easier way of doing this, but I ran across it tonight and thought it was a clever idea. When putting it in your code, it would look something like "Copyright 2001[script goes here]"


Copy this code and paste it in your HTML
  1. <script language="JavaScript">
  2. var d=new Date();
  3. yr=d.getFullYear();
  4. if (yr!=2002)
  5. document.write("-"+yr);
  6. </script>

Report this snippet


Comments


You need to login to view comments.