From: Christopher Brown Date: 2007-02-02T00:24:31+09:00 Subject: Re: convert string to Time? On 01 Feb 2007, at 2:55 PM, _Kevin wrote: > On Jan 31, 5:47 pm, Florian A�mann wrote: >> Look athttp://whytheluckystiff.net/ruby/pickaxe/ >> >> .. see Time.mktime >> >> .. first you should split(' ') ya string and then split the result, >> order da stuff and put it into mktime... >> >> Am 31.01.2007 um 22:20 schrieb Chris McMahon: >> >>> How can I convert a string such as '2007-01-31 12:22:26' to a Time >>> object? > > the ruby-units gem also has a helper for this... > > '2007-01-31 12:22:26'.to_time #=> Wed Jan 31 12:22:26 EST 2007 > > _Kevin > > Time. parse seems to do the trick too... irb(main):003:0> Time.parse("2007-01-31 12:22:26") => Wed Jan 31 12:22:26 SAST 2007