作者:傻丫头苏婵_596 | 来源:互联网 | 2023-09-13 22:32
时区(timezone)转换函数:convert_tz(dt,from_tz,to_tz)
select convert_tz('2008-08-08 12:00:00', '+08:00', '+00:00'); -- 2008-08-0804:00:00
SELECT CONVERT_TZ(CURDATE(), '+08:00', '+00:00')
时区转换也可以通过 date_add, date_sub, timestampadd 来实现。select date_add('2008-08-08 12:00:00', interval -8 hour); -- 2008-08-08 04:00:00select date_sub('2008-08-08 12:00:00', interval 8 hour); -- 2008-08-08 04:00:00select timestampadd(hour, -8, '2008-08-08 12:00:00'); -- 2008-08-08 04:00:00