From: William James Date: 2007-01-07T04:40:05+09:00 Subject: Re: how to get a time object from a date object ? Devin Mullins wrote: > shawn bright wrote: > > lo there all, i have a date object, and i need to make a time object from > > it. > > i tried the to_i, ( what i really need are the seconds ) but it failed. > > I am > > sure that there is an easy way to do this, i just can't seem to find it. > > Time.local(date.year, date.month, date.day) > > (Courtesy of > http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Date/Conversions.html, > actually.) class DateTime def to_time Time.local( year, month, day, hour, min, sec ) end end puts (DateTime.now - 14).to_time