Adding Date and Time Formats

Posted 2006-12-05…

This is nothing new, but, having seen enough Rails developers using custom helpers to do the same thing, I thought it might warrant a quick tip.

If you’re entering dates/times in your fixtures, you’re probably familiar with this trick:

  ---
  item1:
    id: 1
    name: foo
    created_at: <%= 3.days.ago.<b style='color:green;'>to_s(:db)</b>