Time difference in hours

前端 未结 7 1956
不知归路
不知归路 2020-12-04 16:27

I am trying to get the difference in hours for two different Time instances. I get these values from the DB as a :datetime column

How can I do this so that it inclu

7条回答
  •  温柔的废话
    2020-12-04 16:50

    Try Time Difference gem for Ruby at https://rubygems.org/gems/time_difference

    start_time = Time.new(2013,1)
    end_time = Time.new(2014,1)
    TimeDifference.between(start_time, end_time).in_years
    

提交回复
热议问题