MYSQL Handling Time Zones
Retrieve the current date and time in a particular time zone
This fetches the value of NOW() in local time, in India Standard Time, and then again in UTC.
SELECT NOW();
SET time_zone='Asia/Kolkata';
SELECT NOW();
SET time_zone='UTC';
SELECT NOW();
Convert a stored `DATE` or `DATETIME` value to another time zone
If you have a stored DATE or DATETIME (in a column somewhere) it was stored with respect to some time zone, but in MySQL the time zone is not stored with the value. So, if you want to convert it to another time zone, you can, but you must know the original time zone. Using CONVERT_TZ() does the conversion. This example shows rows sold in California in local time.
SELECT CONVERT_TZ(date_sold,'UTC','America/Los_Angeles') date_sold_local
FROM sales
WHERE state_sold = 'CA'
Retrieve stored `TIMESTAMP` values in a particular time zone
This is really easy. All TIMESTAMP values are stored in universal time, and always converted to the present time_zone setting whenever they are rendered.
SET SESSION time_zone='America/Los_Angeles';
SELECT timestamp_sold
FROM sales
WHERE state_sold = 'CA'
Why is this? TIMESTAMP values are based on the venerable UNIX time_t data type. Those UNIX timestamps are stored as a number of seconds since 1970-01-01 00:00:00 UTC.
Notice TIMESTAMP values are stored in universal time. DATE and DATETIME values are stored in whatever local time was in effect when they were stored.