[TZInfo-users] Using TZ to convert to EST

John Sheahan johnsheahan at charter.net
Tue Nov 13 09:01:28 EST 2007

Thanks alot for pointing me in the right direction, Philip.
Your explaination caused me to look hard at my Timezone.get statement and 
found that I was missing the _ between New and York.
Once I fixed this, I am now getting time on my view, however, it is still in 

Here's my code that is giving me UTC:
tz = TZInfo::Timezone.get('America/New_York')
@local = tz.utc_to_local(tz.now)

My service provider that my server is in is giving me Mountain Time, now 
that I have been able to change this to UTC, How can I change this to 
convert the UTC time to EST?


----- Original Message ----- 
From: "Philip Ross" <phil.ross at gmail.com>
To: "General discussion for TZInfo users" <tzinfo-users at rubyforge.org>
Sent: Tuesday, November 13, 2007 5:08 AM
Subject: Re: [TZInfo-users] Using TZ to convert to EST

> On 13/11/2007, John Sheahan <johnsheahan at charter.net> wrote:
>> I then put the following under one of my definitions in my controller for
>> the page I want the time to be displayed on:
>>       tz = TZInfo::Timezone.get('America/New_York')
>>      @local = tz.utc_to_local(Time.utc(2005,8,29,15,35,0))
>> I was trying to call this in my view with this statement which doesn't 
>> work:
>>     <td><%=@ local %></td>
>> I'm obviously calling this incorrectly, would you have any suggestions?
>> The error I'm getting in my log is:
>> TZInfo::InvalidTimezoneIdentifier (Invalid identifier):
>> /usr/local/ruby/lib/ruby/gems/1.8/gems/tzinfo-0.3.5/lib/tzinfo/timezone.rb:81:in
>> `get'
>>     /app/controllers/buy_controller.rb:28:in `indexadmin'
> This error is raised by Timezone.get if the identifier passed in does
> not match the following regular expression:
> ^[A-z0-9\+\-_]+(\/[A-z0-9\+\-_]+)*$
> In the code you've posted above you have 'America/New_York' as the
> identifier, which does match the expression. The above controller code
> works fine.
> Does line 28 of your buy_controller.rb use the hardcoded string
> 'America/New_York' or something else?
> You also need to change your view to remove the space between @ and
> local (although, this isn't causing the above error):
>  <td><%=@local %></td>
> Regards,
> Phil
> --
> Phil Ross
> http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
> _______________________________________________
> TZInfo-users mailing list
> TZInfo-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/tzinfo-users 

More information about the TZInfo-users mailing list