Time difference in hours

前端 未结 7 1914
不知归路
不知归路 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 17:00

    this works great, example for number of hours since user created account

    (Time.parse(DateTime.now.to_s) - Time.parse(current_user.created_at.to_s))/3600
    

提交回复
热议问题