Mysql 时区修正

查看Mysql 当前的时区

SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP); 

待导入的数据时间格式

2020-04-01T08:24:37-04:00

修正时区并创建新表

SELECT
    id,
    title,
    sublocation,
    url,
    description,
    created_at AS time_full,
    substring( created_at,- 6 ) AS time_zone,
    CONVERT_TZ(
        substring( created_at, 1, 19 ),
        substring( created_at,- 6 ),
        '-05:00' 
    ) AS created_at ,
        CONVERT_TZ(
        substring( created_at, 1, 19 ),
        substring( created_at,- 6 ),
        '-05:00' 
    ) AS updated_at 
FROM
    `external_projects` 
    LIMIT 50

你可能感兴趣的:(Mysql 时区修正)