How to insert local time with mysql trigger -


have shared server , running mysql trigger in time being inserted column follows -

insert mytable set time=now(); 

the table , column time gets gmt time.

i want local time inserted table , column.

tried code still giving gmt time on insertion -

set @localtime = convert_tz('now()','gmt','+5:30');  insert mytable set time=@localtime; 

the column time has settings of timestamp default , if change settings varchar, gives error - "#1048 - column 'time' cannot null"

please help.

i found answer question -

set @localtime = (select convert_tz('now()','@@session.time_zone','+5:30'));  insert mytable set time=@localtime; 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -