# Timezone abbreviation question

**URL:** <https://www.ruby-forum.com/t/timezone-abbreviation-question/83279>\
**Category:** Rails\
**Created:** [January 24, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/timezone-abbreviation-question/83279 "2007-01-24T21:38:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [January 24, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/timezone-abbreviation-question/83279/1 "2007-01-24T21:38:27Z")

</div>

Is it possible to get timezone abbreviations using the TimeZone or  
TzinfoTimezone classes? Even after converting UTC to localtime it still  
reports the timezone abbreviation as UTC.

Example:

> > @tz = TzinfoTimezone.us\_zones[2]  
> > =\> #\<TzinfoTimezone:0x30868a0 @utc\_offset=-28800, @name=“Pacific Time  
> > (US & Canada)”\>
> 
> > @tz.now  
> > =\> Wed Jan 24 12:36:56 UTC 2007
> 
> > @tz.now.strftime("%Z")  
> > =\> “UTC”

It seems to me that the timezone abbreviation (%Z) should be “PST” in  
this case.

---

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [January 25, 2007, 12:10am UTC](https://www.ruby-forum.com/t/timezone-abbreviation-question/83279/2 "2007-01-25T00:10:52Z")

</div>

Sorry about the reply-to-myself, but I found the answer.

The tzinfo gem has its own strftime method which returns the correct  
local timezone abbreviation for %Z. TzinfoTimezone plugin does not wrap  
this method. It was very simple to add to the plugin:

def strftime(string, time=Time.now.utc)  
tzinfo.strftime(string, time)  
end

I’m sending this to the author as well.
