How to Convert UTC Date To Local time Zone in MySql Select Query

mahabub.devs3
Mahabubur Rahman
Published on Sep, 22 2024 1 min read 0 comments
image

 

SELECT CONVERT_TZ(displaytime,'GMT','MET');


should work if your column type is timestamp, or date

Test how this works:

SELECT CONVERT_TZ(a_ad_display.displaytime,'+00:00','+04:00');

Check your timezone-table

SELECT * FROM mysql.time_zone;
SELECT * FROM mysql.time_zone_name;

If those tables are empty, you have not initialized your timezone tables. According to link above you can use mysql_tzinfo_to_sql program to load the Time Zone Tables. Please try this

shell> mysql_tzinfo_to_sql /usr/share/zoneinfo

 

 

 

0 Comments