Brian Adkins
2/23/2008 3:43:00 PM
On Feb 22, 12:43 pm, Justin Collins <justincoll...@ucla.edu> wrote:
> Wes Gamble wrote:
>
> <snip>
>
> > If there is a simpler way to ask for a DateTime object that represents
> > the current, local time, I was unable to find it.
>
> > Wes
>
> That is precisely what I get with DateTime.now. Maybe your machine is
> set to GMT?
>
> irb(main):001:0> require 'date'
> => true
> irb(main):002:0> d = DateTime.now
> => #<DateTime: 5890846158565549/2400000000,-1/3,2299161>
> irb(main):003:0> d.strftime
> => "2008-02-22T09:35:08-08:00"
> irb(main):004:0> d.hour
> => 9
> irb(main):005:0> d.min
> => 35
> irb(main):006:0> d.sec
> => 8
> irb(main):007:0> d.zone
> => "-08:00"
>
> -Justin
Yep, local time here also:
irb(main):001:0> require 'date'
=> true
irb(main):002:0> puts DateTime.now
2008-02-23T10:41:51-05:00