iAsk: showing UTC as PST with to_pst?

Does anybody out there know how to change UTC to PST?

I’ve been banging my heads on the wall since yesterday and what I know
is only set time to PST instead of UTC. Please help…

m:x arie$ script/console
Loading development environment (Rails 2.0.2)

Time.zone
=> #<TimeZone:0x211c608 @utc_offset=-28800, @name=“Pacific Time (US &
Canada)”>

Time.zone.now
=> Thu, 27 Mar 2008 03:37:05 PDT -07:00

Time.now
=> Thu Mar 27 18:37:21 +0800 2008

a = Time.now
=> Thu Mar 27 18:41:20 +0800 2008

a.to_pst

I only need to show that “a” in PST instead of UTC. Any ideas?


blog: http://tinyurl.com/2bjgvn,
ruby: http://www.ruby-lang.org/id/about

I always thought Smalltalk would beat Java, I just didn’t know it
would be called ‘Ruby’ when it did. – Kent Beck.

The Time class (frustratingly) fails to keep track of time zone. It
always
deals with UTC. Always. No matter what it tells you it is doing.
Checkout
TZTime for getting around this in Rails. As for Ruby’s core libraries
you
end up using TzInfo and translating input and output into a time object
and
a tzinfo object.

Rob

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs