2
我正在使用Ruby 2.2和Rails 4以及时差被错误计算的sqlite数据库的项目。在Rails 4中错误计算时间差异
为此,我使用了TimeDifference方法。
在我的数据库中有一个表MachineAttendance。
银泰2017年2月12日20点30分00秒UTC 00存储为星期二,:2017年2月12日00
OutTime存储为星期二,五时30分00秒UTC 00:00
@c1.in_time.strftime("%I:%M %p")
"08:30 PM"
@c1.out_time.strftime("%I:%M %p")
"05:30 AM"
And my method is
time_diff=TimeDifference.between(@c1.in_time.strftime('%H:%M:%S'), @c1.out_time.strftime('%H:%M:%S')).in_hours.to_f
its giving 15.0 hrs which is wrong
as it should be 9.0 hrs.
会有人让我知道如何我可以得到正确的区别.....谢谢:)
不知道为什么它不适合我。 –
有一次它的工作..但现在它不工作。 –
Tnx它为我工作。 :) –