how to get the time difference from 2 DateTime objects

S

Schüle Daniel

Hi,

how can I get the time difference in say seconds
between 2 DateTime objects? their difference returns
a rational number which semantic is unclear to me.
(I would expect to get some kind of TimeDelta object
with seconds as its method)

irb(main):107:0* i=DateTime.now;sleep 10;j=DateTime.now;
irb(main):108:0* j-i
=> Rational(10000217, 86400000000)

Thanks in advance
 
R

Robert Klemme

Hi,

how can I get the time difference in say seconds
between 2 DateTime objects? their difference returns
a rational number which semantic is unclear to me.
(I would expect to get some kind of TimeDelta object
with seconds as its method)

irb(main):107:0* i=DateTime.now;sleep 10;j=DateTime.now;
irb(main):108:0* j-i
=> Rational(10000217, 86400000000)

Thanks in advance
=> 10.0

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top