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

后端 未结 3 1086
夕颜
夕颜 2020-11-28 08:01

I am using this Where Condition in One Of my query with MySql Database.My Problem is that i have one displaytime column in my table but that table column shows the data in

3条回答
  •  旧巷少年郎
    2020-11-28 08:23

     select convert_tz(now(),@@session.time_zone,'+05:30')
    

    replace '+05:30' with desired timezone. see here - https://stackoverflow.com/a/3984412/2359994

    to format into desired time format, eg:

     select DATE_FORMAT(convert_tz(now(),@@session.time_zone,'+05:30') ,'%b %d %Y %h:%i:%s %p') 
    

    you will get similar to this -> Dec 17 2014 10:39:56 AM

提交回复
热议问题