为什么把偏移量保存在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).

Examples:

-5:00 Guayaquil, ECU

-4:30 Caracas, VEN

0:00 Some city

2:00 Bonn, GER

解决方案

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.

From the docs:

MySQL retrieves and displays TIME values in 'HH:MM:SS' format (or

'HHH:MM:SS' format for large hours values). TIME values may range from

'-838:59:59' to '838:59:59'. The hours part may be so large because

the TIME type can be used not only to represent a time of day (which

must be less than 24 hours), but also elapsed time or a time interval

between two events (which may be much greater than 24 hours, or even

negative).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值