Showing posts with label date diffrence in ruby on rails. Show all posts
Showing posts with label date diffrence in ruby on rails. 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