This article is half-done without your Comment! *** Please share your thoughts via Comment ***
When we are working with the big distributed database system, it is very important to take care of the default database time zone.
When we are selecting data from different countries, we should always work with UTC time zone because it is a World’s time standard and stand for Universal Time Coordinated.
In one of our MySQL Database Server, we have stored all Date Time-related information based on local time zone.
But now, the problem is some of the users are manipulating the same server from the different country.This is creating a big problem for us because we cannot identify accurate Date Time values.
The solution of this problem is to convert local time zone values into UTC time zone values.
SELECT local time:
1 |
SELECT NOW() AS Local_DateTime; |
SELECT UTC time:
1 |
SELECT UTC_TIMESTAMP() AS UTC_DateTime; |
Convert local time to UTC time:
1 |
SELECT CONVERT_TZ(NOW(), @@session.time_zone, '+00:00') AS UTC_DateTime; |
My suggestion is to store all Date_Time information under UTC time zone only.