Happy #{Time.now.strftime(‘%Y’)}!

Here’s a little programming tip I picked up a while back: it’s embarrassing when one of your web site still reads “Copyright 2007” as the clock turns to 2010.  But who has time to remember every footer on every site that they add a copyright notice?

The trick is to replace the hardcoded year with a snippet of text that evaluates the current year.  Now all your sites will autoupdate at midnight every year:

Copyright &copy; <%= Time.now.strftime(‘%Y’) %>

Happy New Year!

Friday, January 1, 2010