gpt4 book ai didi

mysql - 在 MySQL 中存储 UTC 偏移量的数据类型

转载 作者:行者123 更新时间:2023-11-29 00:13:16 27 4
gpt4 key购买 nike

我有一个 MySQL 时区表,我在其中存储和排序 UTC 偏移量。 UTC 偏移量具有 +03:00、-10:00、+00:00、+05:30 等值。可以找到完整列表 here .

我应该使用什么数据类型来存储这个 UTC 偏移量列?我目前正在使用 time 数据类型,它向每个 UTC 偏移量附加一个额外的“:00”秒。我还尝试使用 varchar,这很好,但对于其他数据库管理员来说可能在语义上没有意义。

更新

我也在考虑使用 int,每个偏移量都表示为秒数。这将使该列非常容易排序。

最佳答案

它看起来非常适合 TIME 数据类型。

TIME

A time. The range is '-838:59:59' to '838:59:59'. MySQL displays TIME values in 'HH:MM:SS' format, but permits assignment of values to TIME columns using either strings or numbers.

关于mysql - 在 MySQL 中存储 UTC 偏移量的数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23915459/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com