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_pstI 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. ------------------------------------ ID-Ruby Berdiskusi dan belajar bersama Bahasa Pemrograman Ruby, termasuk segala varian Ruby (JRuby, Rubinius, IronRuby, XRuby), dan program yang dibuat dengan Ruby (Ruby on Rails, JRuby on Rails, Merb) <*> Kunjungi *arsip milis* id-ruby di http://groups.yahoo.com/group/id-ruby/messages http://www.mail-archive.com/id-ruby-hHKSG33TihhbjbujkaE4pw@public.gmane.org/ http://rubyurl.com/Q8DD http://news.gmane.org/gmane.comp.lang.ruby.region.indonesia <*> Baca peraturan id-ruby sebelum posting http://rubyurl.com/gay1 <*> Ikutilah Jajak Pendapat ID-Ruby http://rubyurl.com/3CCt <*> Links ID-Ruby http://rubyurl.com/n96r <*> Database ID-Ruby http://rubyurl.com/Iw3u <*> Kunjungi Situs Resmi Ruby Indonesia http://www.ruby-lang.org/id/ <*> Join Ruby Indonesia on Facebook http://rubyurl.com/QV48 <*> Join Ruby Indonesia on LinkedIn http://rubyurl.com/eh0i Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/id-ruby/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/id-ruby/join (Yahoo! ID required) <*> To change settings via email: mailto:id-ruby-digest-hHKSG33TihhbjbujkaE4pw@public.gmane.org mailto:id-ruby-fullfeatured-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> To unsubscribe from this group, send an email to: id-ruby-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
On 27/03/2008, Edwin Pratomo <edpratomo-/E1597aS9LSez0ei9/+7zw@public.gmane.org> wrote:> 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...> rgds, > Edwin.-- 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. ------------------------------------ ID-Ruby Berdiskusi dan belajar bersama Bahasa Pemrograman Ruby, termasuk segala varian Ruby (JRuby, Rubinius, IronRuby, XRuby), dan program yang dibuat dengan Ruby (Ruby on Rails, JRuby on Rails, Merb) <*> Kunjungi *arsip milis* id-ruby di http://groups.yahoo.com/group/id-ruby/messages http://www.mail-archive.com/id-ruby-hHKSG33TihhbjbujkaE4pw@public.gmane.org/ http://rubyurl.com/Q8DD http://news.gmane.org/gmane.comp.lang.ruby.region.indonesia <*> Baca peraturan id-ruby sebelum posting http://rubyurl.com/gay1 <*> Ikutilah Jajak Pendapat ID-Ruby http://rubyurl.com/3CCt <*> Links ID-Ruby http://rubyurl.com/n96r <*> Database ID-Ruby http://rubyurl.com/Iw3u <*> Kunjungi Situs Resmi Ruby Indonesia http://www.ruby-lang.org/id/ <*> Join Ruby Indonesia on Facebook http://rubyurl.com/QV48 <*> Join Ruby Indonesia on LinkedIn http://rubyurl.com/eh0i Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/id-ruby/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/id-ruby/join (Yahoo! ID required) <*> To change settings via email: mailto:id-ruby-digest-hHKSG33TihhbjbujkaE4pw@public.gmane.org mailto:id-ruby-fullfeatured-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> To unsubscribe from this group, send an email to: id-ruby-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
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 On Thu, Mar 27, 2008 at 3:48 AM, Rie! <ariekusumaatmaja2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---