William James wrote:
> Dan Fitzpatrick wrote:
> > shawn bright wrote:
> > > lo there all,
> > >
> > > i am wrestling with this for a bit now. how do i get a time object for
> > > two
> > > weeks ago ?
> > > if
> > > t = Time.now, how do i get t - 2 weeks ?
> > >
> > > thanks
> > >
> > Time is stored in seconds so:
> >
> > Time.now - 60*60*24*14 = 2 weeks ago
> >
> > Dan
>
>
> class DateTime
>   def to_time
>     Time.local( *strftime( "%Y,%m,%d,%H,%M,%S" ).split( "," ).
>       map{|str| str.to_i } )
>   end
> end
>
> puts (DateTime.now - 14).to_time


class DateTime
  def to_time
    Time.local( *strftime( "%Y %m %d %H %M %S" ).split )
  end
end

puts (DateTime.now - 14).to_time