Forum: Ruby Seconds between two dates

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2ff328b063719c06f80c2dff5c96bec4?d=identicon&s=25 fReDiNi (Guest)
on 2009-01-09 12:30
(Received via mailing list)
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.
F1938de600a3feacd015051492fdaf0f?d=identicon&s=25 LAMBEAU Bernard (Guest)
on 2009-01-09 12:40
(Received via mailing list)
I think that the following works:

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

blambeau
2ff328b063719c06f80c2dff5c96bec4?d=identicon&s=25 fReDiNi (Guest)
on 2009-01-09 12:55
(Received via mailing list)
On 9 ene, 12:39, LAMBEAU Bernard <blamb...@gmail.com> wrote:
> > 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.
>
>

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.
This topic is locked and can not be replied to.