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

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -