Question

today = Time.now
  => 2014-01-12 22:24:39 -0500
future = Time.parse("01-03-2014")
  => 2014-03-01 00:00:00 -0500
"%2.f" % ((future - today)/60/60/24)
  => 47 

How else can I get 47 days without having to do /60/60/24 ?

Was it helpful?

Solution

You could compare two dates.

today = Date.today
future = Date.parse("01-03-2014")
days_diff = (future - today).to_i
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top