计算以天、小时和分钟为单位的时间差 [英] calculate difference in time in days, hours and minutes

查看:44
本文介绍了计算以天、小时和分钟为单位的时间差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我正在更新问题以反映完整的解决方案.使用下面提到的 time_diff gem Brett,以下代码有效.

UPDATE: I am updating the question to reflect the full solution. Using the time_diff gem Brett mentioned below, the following code worked.

代码:

cur_time = Time.now.strftime('%Y-%m-%d %H:%M')
Time.diff(Time.parse('2011-08-12 09:00'), Time.parse(cur_time))

谢谢,布雷特.

推荐答案

我已经使用 time_diff 来实现这种事情之前很容易,你可能想看看.

I've used time_diff to achieve this sort of thing easily before, you may want to check it out.

这篇关于计算以天、小时和分钟为单位的时间差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆