Generate year using Javascript
The footer-year trick: a snippet that keeps a copyright date current without touching the page.
Many times when you write a simple HTML page, at the footer you’ll need to include the year in the copright statement. For eg.,
Copyright © 2010 Gautham Ponnu
Many a time, in an infrequently updated site I often forget to update the year at the footer. This was until I came across this useful code snippet to generate the current year using simple javascript.
<script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script>
So, a typical usage of this piece of code would be like this.
<p>Copyright © <script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script> <a href="http://gauthamponnu.com">Gautham Ponnu</a>
All rights reserved.</p>
Please look at the code. Get inspired. Don't steal.
This will produce the above output.