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
如何在不必/60/60/24
的情况下获得47天?
答案 0 :(得分:0)
你可以比较两个日期。
today = Date.today
future = Date.parse("01-03-2014")
days_diff = (future - today).to_i