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?
i don't think I fully understand your question.
but displaying time in certain timezone is fairly easy (in UNIX-based system).
$ ruby -e'p Time.now'
Thu Mar 27 18:28:12 +0700 2008
$ env TZ="US/Pacific" ruby -e'p Time.now'
Thu Mar 27 04:27:29 -0700 2008
is that you are asking about? if so, then I have saved your head 
No, what I want to get is only displaying what current UTC Time to be
PST instead of also UTC. BTW my server is already UTC and I *don't*
want to change its setting to be PST. Just imagine this scenario, one
day a customer will say: "We need it to be based by Europe Paris
instead of PST"
chang@chang [~]# date
Thu Mar 27 11:43:32 UTC 2008
I need to display something like if I say: Time.now.to_pst , will show
PST, not UTC.
I've read jamisbuck's post about tzinfo about deprecated and obsolete,
and also rick's posts of Time.zone.now but I have no idea how to *get*
Pacific Time (US & Canada) Time, I only know how to _set_ it. I even
read one of jamisbuck blog comments saying that time and date
implementation in Ruby should be changed # Nope, I'm not saying
current implementation is good nor bad, I'm just frustrated I guess
:((
My heads are still bleeding.
Help...
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