django日期查询出现UTC日志转换CONVERT_TZ出错的问题

select CONVERT_TZ(NOW(), 'UTC', 'UTC') 出现NULL值,
原因是MySQL少了时区表:
SELECT * FROM mysql.time_zone;
SELECT * FROM mysql.time_zone_name;

上面留个表查询为空是错误的原因。

解决办法:

登录linux在命令窗口执行下面语句:

mysql_tzinfo_to_sql /usr/share/zoneinfo

 参考:

https://dev.mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html

https://stackoverflow.com/questions/15017799/how-to-convert-utc-date-to-local-time-zone-in-mysql-select-query

http://www.dannysite.com/blog/84/

http://www.voidcn.com/blog/edwingu/article/p-2442244.html

http://blog.csdn.net/wy00703/article/details/45071277

https://dev.mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html

https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html

 

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

 https://stackoverflow.com/questions/18216198/unable-to-load-timezones/18216945

posted on 2017-07-14 17:36  VincentZhu  阅读(374)  评论(0编辑  收藏  举报