Timestamp difference

How would you find out whether the time difference of one timestamp to
another is
greater than 5?

I’ve tried this

(old_time - Time.now) > 5

On Fri, Jan 21, 2011 at 9:46 AM, Benjamin F. [email protected]
wrote:

How would you find out whether the time difference of one timestamp is
greater than 5?

I’ve tried this

(old_time - Time.now) > 5

and??

start = Time.now
=> Fri Jan 21 09:49:23 -0800 2011
stop = Time.now
=> Fri Jan 21 09:49:52 -0800 2011
(stop - start)
=> 29.616956
(stop - start) > 5
=> true

Try

(Time.now.to_i - old_time.to_i) > 5 # seconds

Thanks alot, works perfectly

On Jan 21, 2011, at 12:46 PM, Benjamin F. wrote:

How would you find out whether the time difference of one timestamp is
greater than 5?

I’ve tried this

(old_time - Time.now) > 5

In addition to the other responses, I’ll point out that you have (past

  • now) which will always be <=0 the therefore NEVER > 5.

-Rob

Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/