Ruby on Rails Blog
Ruby on rails blog
Showing posts with label
ruby on rails date diffrence
.
Show all posts
Showing posts with label
ruby on rails date diffrence
.
Show all posts
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
Home
Subscribe to:
Posts (Atom)