[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Seconds between two dates

fReDiNi

1/9/2009 11:26:00 AM

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.
2 Answers

LAMBEAU Bernard

1/9/2009 11:39:00 AM

0

I think that the following works:

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

blambeau

On Fri, Jan 9, 2009 at 12:29 PM, fReDiNi <freduchi@gmail.com> wrote:
> 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.
>
>

fReDiNi

1/9/2009 11:51:00 AM

0

On 9 ene, 12:39, LAMBEAU Bernard <blamb...@gmail.com> wrote:
> I think that the following works:
>
> (Time.now-Time.gm(2009,"may",8,17,00,00)).to_i
>
> blambeau
>
> On Fri, Jan 9, 2009 at 12:29 PM, fReDiNi <fredu...@gmail.com> wrote:
> > 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.
>
>

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.