Newbie Question on Time

This may be ridiculously easy, but what is the best way to format/
calculate how much time has passed since a record was created. I have
a created_at field in my table and I want to say that a record was
created XXXX ago, for instance 2 days 1 hour ago.
Thanks,
JB

Rails to the rescue - “time_ago_in_words” will do what you need

time_ago_in_words(Time.now - (10.hours + 25.minutes)) # outputs =>
“About 10 hours”

Thanks dang.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs