How to Convert Timezone in MySQL Using Timezone Name

MySQLmysql-5.5timezone

I want to convert date from one timezone to another timezone in MySQL, MySQL query which I am trying is

SELECT DATE_FORMAT(CONVERT_TZ('2015-12-18 06:00:00', '+0:00', '-05:00' ),'%b %d %Y %h:%i %p') AS test
FROM appointment

which is working properly. Now the issue I am having is that my database uses the timezone name as America/New_York.

Is there any way to convert timezone using timezone name not from timezone offset?

Best Answer

To answer the question:

Is there any way to convert timezone using timezone name not from timezone offset

The function CONVERT_TZ has this example and warning:

mysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
    -> '2004-01-01 13:00:00'

Note To use named time zones such as 'MET' or 'Europe/Moscow', the time zone tables must be properly set up. See Section 10.6, “MySQL Server Time Zone Support”, for instructions.

And the section on Time Zone support has a 'Populating the Time Zone Tables' section which describes the process of setting up the mysql timezone tables.