# Time zone mapping from TimeZone to TZInfo::Timezone

**URL:** <https://www.ruby-forum.com/t/time-zone-mapping-from-timezone-to-tzinfo-timezone/92461>\
**Category:** Rails\
**Created:** [April 19, 2007, 7:50pm UTC](https://www.ruby-forum.com/t/time-zone-mapping-from-timezone-to-tzinfo-timezone/92461 "2007-04-19T19:50:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![morten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@morten](https://www.ruby-forum.com/u/morten)\
**Post date:** [April 19, 2007, 7:50pm UTC](https://www.ruby-forum.com/t/time-zone-mapping-from-timezone-to-tzinfo-timezone/92461/1 "2007-04-19T19:50:35Z")

</div>

Hi. Using this:

```
<%= time_zone_select("account", "time_zone" %>

```

I get a list of time zones options, like eg.:

```
<option value="Athens">(GMT+02:00) Athens</option>

```

But as I’m using TZInfo::Timezone, I need to map ‘Athens’ to  
‘Europe/Athens’

I can see that the mapping I’m looking for is present in the  
tzinfo\_timezone plugin, but I cannot see how to access it.

Anyone?

Thanks.

Morten

PS: I’m aware that I could use

\<%=time\_zone\_select(“account”, “time\_zone”,  
TZInfo::Timezone.all.sort, :model =\> TZInfo::Timezone) %\>

But the resulting select values look horrible, so I’d like to stick  
with the Rails presentation format.

---

<div class="post-metadata">

**Author:** ![morten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@morten](https://www.ruby-forum.com/u/morten)\
**Post date:** [April 28, 2007, 6:05pm UTC](https://www.ruby-forum.com/t/time-zone-mapping-from-timezone-to-tzinfo-timezone/92461/2 "2007-04-28T18:05:32Z")

</div>

Hi Morten,

\<%=time\_zone\_select(“account”, “time\_zone”,  
TZInfo::Timezone.all.sort, :model =\> TZInfo::Timezone) %\>

Actually the code you mentioned above will give a result in the format  
you are looking for.  
i.e ‘Europe/Athens’

$tcode = @params[:account][:time\_zone]  
tz = TZInfo::Timezone.get($tcode)  
tz = tz.local\_to\_utc(Time::now()).to\_s

So, ‘tz’ will provide you the converted time.

Hope it helps you and others.

Thanks,  
Selva
