The Ruby on Rails and ClojureScript experts

Dec 7, 2008

I have used strftime a lot lately on one of my projects. I could not find a user friendly reference for strftime, so I wrote one. Here is my user friendly strftime cheat sheet in PDF format:

strftime reference

In case you are wondering what strftime does: It allows you to represent a date/time as a formatted string. Example:

Time.now.strftime('%A, %l:%M %p')
=> "Friday,  9:06 AM"

And here is some handy Ruby code to look at the options for strftime:

def print_line(char)
  puts "%#{char}: #{Time.now.strftime("%#{char}")}"
end

('a'..'z').each do |char|
  print_line(char)
  print_line(char.upcase)
end