MySQL CONVERT_TZ() Function
In MySQL, the CONVERT_TZ() function converts a time in one time zone to the time in another time zone.
CONVERT_TZ() Syntax
Here is the syntax of MySQL CONVERT_TZ() function:
CONVERT_TZ(datetime, from_time_zone, to_time_zone)
Parameters
- datetime
- Required. The datetime that needs to be processed. It must be a datetime value.
- from_time_zone
- Required. The current time zone.
- to_time_zone
- Required. A new time zone.
from_time_zone and to_time_zone supported the following items:
- Using SYSTEMmeans the same as the current system’s time zone.
- Using +/-[H]H:MMmeans an offset from UTC, eg'+10:00','-6:00', ,'+05:30'etc.
- Use the name of the time zone, eg: 'Europe/Helsinki','US/Eastern','MET','GMT'.
Return value
The CONVERT_TZ() function returns a datetime in the new time zone. It will return NULL if the argument is error or NULL.
CONVERT_TZ() Examples
Here are some examples of the CONVERT_TZ() function.
SELECT
    CONVERT_TZ('2021-12-01 12:00:00', 'GMT', 'MET'),
    CONVERT_TZ('2021-12-01 12:00:00', 'GMT', '+01:00'),
    CONVERT_TZ('2021-12-01 12:00:00', 'GMT', '-01:00'),
    CONVERT_TZ('2021-12-01 12:00:00', 'GMT', '-03:00')\G
   CONVERT_TZ('2021-12-01 12:00:00', 'GMT', 'MET'): 2021-12-01 13:00:00
CONVERT_TZ('2021-12-01 12:00:00', 'GMT', '+01:00'): 2021-12-01 13:00:00
CONVERT_TZ('2021-12-01 12:00:00', 'GMT', '-01:00'): 2021-12-01 11:00:00
CONVERT_TZ('2021-12-01 12:00:00', 'GMT', '-03:00'): 2021-12-01 09:00:00