Mysql Set Timezone Utc

Posted on by admin
  1. No matter what timezone the current MySQL session is in: SELECT CONVERTTZ (`timestampfield`, @@session.timezone, '+00:00') AS `utcdatetime` FROM `tablename`. You can also set the sever or global or current session timezone to UTC and then select the timestamp like so: SELECT `timestampfield` FROM `tablename`.
  2. If changing the timezone on your running production servers or updating a key configuration setting and restarting mysql seems unrealistic and/or overkill, try this: CONVERTTZ (NOW , 'US/Pacific', 'UTC') Where US/Pacific is the timezone your NOW call is returning the time in.

In MySQL the CONVERTTZ returns a resulting value after converting a datetime value from a time zone specified as the second argument to the time zone specified as the third argument. This function returns NULL when the arguments are invalid. Syntax: CONVERTTZ (dt, fromtz,totz) Arguments. UTCTIMESTAMP function. In MySQL, the UTCTIMESTAMP returns the current UTC date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS.uuuuuu format depending on the usage of the function i.e. In a string or numeric context. If I’m trying to store 2016-06-01 23:52:17 right now, it will store it as 2016-06-01 22:52:17, because that’s the time in UTC. If I were to set the timezone to something else, like SET timezone = '+8:00', then saving the same 2016-06-01 23:52:17 date will result in an internal datetime of 2016-06-01 15:52:17.

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.

Mysql Check Timezone

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.

Mysql Set Timezone Utc

The solution of this problem is to convert local time zone values into UTC time zone values.

Mysql configure timezone utc

SELECT local time:


Convert local time to UTC time:

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.

Mysql Set Timezone Utc

Please visit other related articles...


MySQL Database on Azure currently supports changing the time zone by modifying the parameter settings. Log in to the Azure Management Portal and change the time_zone parameter within the server parameters. The system time for MySQL Database on Azure currently defaults to Coordinated Universal Time (UTC), but you can update the time by configuring the offset value. For example, +08:00 corresponds to UTC+8 (Beijing time), while -06:00 corresponds to the UTC-6 time zone.

See Customize MySQL Database on Azure server parameters for details of specific intervals and other parameters.

Mysql Set Timezone Utc Password

Taking the example of a user that wishes to switch to Beijing time, the user can set the time_zone parameter to +08:00 as shown in the image below.


Set Time Zone Yahoo Mail


Mysql Set Timezone Utc Clock

The use of named regions such as “Europe/Helsinki”, “US/Eastern” or “MET” is not currently supported.