Ratatouille
Ratatouille

Reputation: 1492

Update all record from UTC to EST timezone + mysql

I trying to update a all the time present in my database to which is UTC to EST format basically -05:00

First Query I running the following query

update time_info set time = SELECT CONVERT_TZ(time,'+00:00','-05:00');

Now this doesnot seem to work

Now There is other way I can achieve this is something like

update time_info set time = time - 5*3600;

But I was thinking just for sake of learning is it possible to run the first query as expected

Upvotes: 0

Views: 2286

Answers (1)

Joni
Joni

Reputation: 111349

For a DATETIME column, you can use the CONVERT_TZ function to convert time zones. Just don't use the SELECT keyword:

update time_info set `time` = convert_tz(`time`, '+00:00','-05:00');

Upvotes: 1

Related Questions