Sterling Rose Design Blog

Perpetual Footer

2 Comments
Tags: date and time Rails
I was spinning up a brand new client website that would (like most websites) include a copyright footer. I wanted to make sure I wouldn’t have to come back year after year and update the year span, so here is what I used:

&copy; 2009<%= "-#{Date.today.year}" if Date.today.year != 2009 %> ABC Company


It will display only 2009 as the copyright year until January 1, 2010, then it will start displaying a span (from 2009 through the current year). Simple.

Uses Rails 2.3.2
Comments

How about: <%= [2009, Date.today.year].uniq.join(“-”) %> just as an alternative ;)

Guess I need to improve my Ruby-fu. ;)


Leave a Comment











Copyright 2007-2010, Sterling Rose Design. All rights reserved.