扫码一下
查看教程更方便
CONVERT_TZ()函数 从一个时区转换为另一个时区。
CONVERT_TZ()函数语法如下
CONVERT_TZ(dt,from_tz,to_tz)
CONVERT_TZ() 函数会将日期时间值 dt 从 from_tz 给定的时区转换为 to_tz 给定的时区,并返回结果值。如果参数无效,此函数返回 NULL。
mysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
+---------------------------------------------------------+
| CONVERT_TZ('2004-01-01 12:00:00','GMT','MET') |
+---------------------------------------------------------+
| 2004-01-01 13:00:00 |
+---------------------------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','+00:00','+10:00');
+---------------------------------------------------------+
| CONVERT_TZ('2004-01-01 12:00:00','+00:00','+10:00') |
+---------------------------------------------------------+
| 2004-01-01 22:00:00 |
+---------------------------------------------------------+
1 row in set (0.00 sec)