From: Joel VanderWerf Date: 2009-07-02T02:50:05+09:00 Subject: Re: date time subtraction aidy wrote: > Hi, > > I am trying to do a subtraction of the date and time in the format > below with the current date and time > > "2009-07-01 18:24:20" > > Will I need to tokenise this string and do individual number > comparisons? irb(main):007:0> require 'time' => true irb(main):009:0> t = Time.parse "2009-07-01 18:24:20" => Wed Jul 01 18:24:20 -0700 2009 irb(main):010:0> t.to_i => 1246497860 irb(main):011:0> t.day => 1 irb(main):012:0> t.hour => 18 See the Time class for details. You can also directly compare time objects (without using to_i to get seconds since the epoch): irb(main):013:0> Time.now < Time.now => true -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407