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 ?

Était-ce utile?

La solution

You could compare two dates.

today = Date.today
future = Date.parse("01-03-2014")
days_diff = (future - today).to_i
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top