本文介绍了数据类型/结构来存储MySQL中的时区偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
哪些是在MySQL中存储时区偏移的正确数据类型/结构?我只想存储数值(城市和国家显然存储在其他列中)。
Which would be the proper datatype/structure to store timezone offsets in MySQL? I just want to store the numeric value (the city and country are obviously stored in other columns).
示例:
- -5:00瓜亚基尔,ECU
- -4:30加拉加斯,VEN
- 0:00城市
- 2:00 Bonn,GER
- -5:00 Guayaquil, ECU
- -4:30 Caracas, VEN
- 0:00 Some city
- 2:00 Bonn, GER
推荐答案
您应该使用。这是任务的正确数据类型:您有格式化和可用。此外,根据文档, TIME
也应该被用作两个时刻之间的差异的结果,这是Timezones实际上的差异。
You should use TIME
. It's the right data type for the task: you have formatting and calculations are available. Moreover, according to the docs, TIME
is also supposed to be used as a result of differences between two moments, which is what Timezones are in fact.
从文档:
这篇关于数据类型/结构来存储MySQL中的时区偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!