Hi all,
I have following two time stamps,
12:35:10:757 & 12:35:10:759
I want to convert them to ruby time and find the time difference.
which is a 2 micro seconds.
I would appreciate any help…
thanks in advance
Hi all,
I have following two time stamps,
12:35:10:757 & 12:35:10:759
I want to convert them to ruby time and find the time difference.
which is a 2 micro seconds.
I would appreciate any help…
thanks in advance
Il 20/09/10 17.21, Ruwan B. ha scritto:
Hi all,
I have following two time stamps,
12:35:10:757& 12:35:10:759
I want to convert them to ruby time and find the time difference.
which is a 2 micro seconds.
Simply:
require ‘time’
mT=Time.utc(2010,9,20,12,35,10,757)
=> Mon Sep 20 12:35:10 UTC 2010
mT1=Time.utc(2010,9,20,12,35,10,759)
=> Mon Sep 20 12:35:10 UTC 2010
mT1-mT
=> 2.0e-06
I would appreciate any help…
thanks in advance
You’re welcome, but before ask, try to google a bit…[1]
Alternative:
require ‘time’
=> truet1 = Time.parse(“12:35:10.000757”)
=> Mon Sep 20 12:35:10 +0100 2010t2 = Time.parse(“12:35:10.000759”)
=> Mon Sep 20 12:35:10 +0100 2010t2 - t1
=> 2.0e-06
Brian C. wrote in post #942410:
Alternative:
require ‘time’
=> truet1 = Time.parse(“12:35:10.000757”)
=> Mon Sep 20 12:35:10 +0100 2010t2 = Time.parse(“12:35:10.000759”)
=> Mon Sep 20 12:35:10 +0100 2010t2 - t1
=> 2.0e-06
If you got the ruby time, you can use the gem ‘time_diff’ to get the
time difference in a useful format like year, month, week, day, hour,
minute, second
On Wed, Mar 9, 2011 at 9:37 AM, ABHILASH M.A [email protected] wrote:
=> 2.0e-06
If you got the ruby time, you can use the gem ‘time_diff’ to get the
time difference in a useful format like year, month, week, day, hour,
minute, second
I haven’t looked at the gem, but…it’s all just simple math, except
for the month part, which takes a bit more work. Does the gem
actually calculate the difference in months between two dates, or
does it just approximate it?
Kirk H.
Software Engineer
EngineYard
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs