Ruby - DateTime, cookbook solution to show the difference between two times is not working, can you see what's wrong?
I have two variables c开发者_如何学运维ontaining dates:
curr_time = Wed Sep 21 11:13:50 -0700 2011
prev_time = Wed, 21 Sep 2011 09:44:56 UTC +00:00
to find out how many minutes have passed between these two I am using the following:
elapsed = ((curr_time - prev_time) / (60)).to_i
However the result is 522, it should be 89 minutes.
I've tried this a few different ways, but I'm clearly missing something here.
Any help would be appreciated!
curr_time = "Wed Sep 21 11:13:50 -0700 2011".to_time
prev_time = "Wed, 21 Sep 2011 09:44:56 UTC +00:00".to_time
((curr_time - prev_time)/60).to_i
=> 88
精彩评论