Code of the Year
Like most people, I have difficulty writing my first cheque of the new year. I always write the wrong year. Apparently, I am also like most web sites.
If this was something that must be done manually, I could understand. But the content on a web page is not written with a Bic Grip Roller. It’s generated by a computer that knows the current year.
Here’s some code you can use to keep your copyright current. Examples for Perl, Python, etc. are appreciated!
<?php echo date("Y");?>
In parsed HTML (aka SHTML, must be enabled in Apache):
<!--#config timefmt=" %Y" --> <!--#echo var="DATE_LOCAL" -->
In Java (JSP, thanks to Tim!):
<%= (new SimpleDateFormat("yyyy")).format( new Date() ) %>
In Smalltalk (thanks to Tim!):
^Date today year asString
In Ruby (thanks to Scott Boms):
add the following to a helper (eg. application_helper)
def copyright_year t = Time.now t.year end
then in the view file, just put <%= copyright_year %>