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
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
On Thursday 09 August 2007 01:29:46 am Jochen K. 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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs