Ruby on Rails Blog
Ruby on rails blog
Wednesday, February 10, 2010
Calculating the Number of Days Between Two Dates in ruby on rails
def room_expiry_date_in_days(room)
a=room.expiry_date.strftime("%Y-%m-%d")
b=room.created_at.strftime("%Y-%m-%d")
a=Date.parse(a)
b=Date.parse(b)
days=(a-b).to_i
return "#{pluralize(days, 'day',"days")} left"
end
No comments:
Post a Comment
Newer Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment