# Convert Rails TimeZone name to MySQL timezone name?

**URL:** <https://www.ruby-forum.com/t/convert-rails-timezone-name-to-mysql-timezone-name/204693>\
**Category:** Rails\
**Created:** [March 18, 2011, 7:27pm UTC](https://www.ruby-forum.com/t/convert-rails-timezone-name-to-mysql-timezone-name/204693 "2011-03-18T19:27:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 18, 2011, 7:27pm UTC](https://www.ruby-forum.com/t/convert-rails-timezone-name-to-mysql-timezone-name/204693/1 "2011-03-18T19:27:10Z")

</div>

For various reasons we need to use the CONVERT\_TZ() function in mysql to  
convert times during queries. The timezone to be used in the conversion  
is based on the timezone the user selected when setting up their profile  
(from a select box populated with ActiveSupport::TimeZone.us\_zone).

The problem is that the zone names in rails differ from the names in  
MySQL.

In rails we have a name like “Eastern Time (US & Canada)”. MySQL has  
the equivalent as the following: “US/Eastern”

Obviously we could write some name mapping thingy or munge the names in  
MySQL time\_zone\_name file. I’m just wondering if anyone has already  
been down this path and has a canned solution.

Thanks in advance.
