I have a PHP application that stores PHP datetime to my MySQL table. I did not noticed that the php server is using wrong timezone settings, so all the date that is stored in the table is incorrect. My timezone is GMT+8 but the PHP ‘date.timezone’ was GMT+0, so I need to add 8 hours to all existing date value in the table.
current data:
ID,session_start,session_close,total_sale
1,2012-01-01 01:35:33,2012-01-01 09:35:33,8211.9
2,2012-01-02 01:32:31,2012-01-02 09:46:54,4323.56
3,2012-01-03 01:21:38,2012-01-03 09:32:21,8732.33
desired data:
ID,session_start,session_close,total_sale
1,2012-01-01 09:35:33,2012-01-01 17:35:33,8211.9
2,2012-01-02 09:32:31,2012-01-02 17:46:54,4323.56
3,2012-01-03 09:21:38,2012-01-03 17:32:21,8732.33
I need to fix the datetime for all the data in my mysql table (add 8 hours more to the original datetime value, to be precise).
I know this can be done by writing a simple PHP script to loop over all rows in that table and modify the datetime value as needed, but it will be fun (and cool too!) if somebody can show me this can be done in MySQL.
1 Answer