From: Kirk Haines Date: 2005-11-14T01:03:49+09:00 Subject: Re: Converting between Time and DateTime On Saturday 12 November 2005 11:35 am, David A. Black wrote: > OK, let me try again. > > irb(main):068:0> t = Time.now > => Sat Nov 12 13:33:08 EST 2005 > irb(main):069:0> d = DateTime.parse(t.iso8601) > => # > irb(main):070:0> d.strftime("%c") > => "Sat Nov 12 13:33:08 2005" > irb(main):071:0> Time.parse(d.strftime("%c")) > => Sat Nov 12 13:33:08 EST 2005 > > 'parse' seems to be a good bet in both directions. It works in both directions because the underlying 'parse' is the same one. :) They all use the same the Date#_parse method defined in date/format.rb. Using this is going to be much slower than just doing conversions with the numerical values and constructor methods that the classes provide. Kirk Haines