# iAsk: showing UTC as PST with to\_pst?

**URL:** <https://www.ruby-forum.com/t/iask-showing-utc-as-pst-with-to-pst/133063>\
**Category:** Rails\
**Created:** [March 27, 2008, 11:48am UTC](https://www.ruby-forum.com/t/iask-showing-utc-as-pst-with-to-pst/133063 "2008-03-27T11:48:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 27, 2008, 11:48am UTC](https://www.ruby-forum.com/t/iask-showing-utc-as-pst-with-to-pst/133063/1 "2008-03-27T11:48:58Z")

</div>

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](http://tinyurl.com/2bjgvn),  
ruby: [Tentang 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.

---

<div class="post-metadata">

**Author:** ![Rie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@Rie](https://www.ruby-forum.com/u/Rie)\
**Post date:** [March 31, 2008, 5:37pm UTC](https://www.ruby-forum.com/t/iask-showing-utc-as-pst-with-to-pst/133063/2 "2008-03-31T17:37:36Z")

</div>

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
