Seconds between two dates

F

fReDiNi

How could I get the seconds between two dates ion Ruby?

I need the seconds remaining from the current date and a date in the
future.

date1: current date, for example 2009-01-09 17:00:00
date 2 : 2009-05-08 17:00:00


How could I get the seconds between these two dates?.


Thanks.
 
L

LAMBEAU Bernard

I think that the following works:

(Time.now-Time.gm(2009,"may",8,17,00,00)).to_i

blambeau
 
F

fReDiNi

I think that the following works:

(Time.now-Time.gm(2009,"may",8,17,00,00)).to_i

blambeau

I think it's working but the operands need to be changed to get the
positive difference in seconds that I needed.

(Time.gm(2009,"may",8,17,00,00)-Time.now).to_i

thank you very much blambeau.
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top