convert_tz

Description

Syntax

DATETIME CONVERT_TZ(DATETIME dt, VARCHAR from_tz, VARCHAR to_tz)

Convert datetime value. Go from the given input time zone to the specified time zone and return the result value. If the argument is invalid, the function returns null.

Example

  1. mysql> select convert_tz('2019-08-01 13:21:03', 'Asia/Shanghai', 'America/Los_Angeles');
  2. +---------------------------------------------------------------------------+
  3. | convert_tz('2019-08-01 13:21:03', 'Asia/Shanghai', 'America/Los_Angeles') |
  4. +---------------------------------------------------------------------------+
  5. | 2019-07-31 22:21:03 |
  6. +---------------------------------------------------------------------------+
  7. mysql> select convert_tz('2019-08-01 13:21:03', '+08:00', 'America/Los_Angeles');
  8. +--------------------------------------------------------------------+
  9. | convert_tz('2019-08-01 13:21:03', '+08:00', 'America/Los_Angeles') |
  10. +--------------------------------------------------------------------+
  11. | 2019-07-31 22:21:03 |
  12. +--------------------------------------------------------------------+

keywords

  1. CONVERT_TZ