[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

calculating the difference of to dates

jochen kaechelin

8/9/2007 8:30:00 AM

I want to calculate the difference (days, hours, minutes)
between a given date out of a mysql database (2007-07-07, date) and
the current date (Time.now).

How can I achieve this?

Thanx


--
Jochen Kaechelin
railswerk.de, gissmoh.de, figgfrosch.de, ror-ror.de

1 Answer

Konrad Meyer

8/9/2007 9:25:00 AM

0

On Thursday 09 August 2007 01:29:46 am Jochen Kaechelin wrote:
> I want to calculate the difference (days, hours, minutes)
> between a given date out of a mysql database (2007-07-07, date) and
> the current date (Time.now).
>
> How can I achieve this?

ex:

require 'parsedate'

sql_time = Time.mktime(*ParseDate.parsedate("2007-07-07"))
cur_time = Time.now

difference = cur_time - sql_time # result will be in seconds

Hope that helps.
--
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertil...