gpt4 book ai didi

MySQL存储不同时区的播放列表

转载 作者:行者123 更新时间:2023-11-29 14:31:12 25 4
gpt4 key购买 nike

我需要在数据库中创建一个播放列表,以了解播放器何时播放每个视频。我将使用这样的东西:表播放列表包含:id、video_id、play_time 例如,如果 play_time 为 2012-04-10 14:00:00,则视频应在 2012-04-10 的 14:00:00 播放,但是与用户所在时区相关。

对于这个日期时间或时间戳使用什么更好?

最佳答案

来自MySQL manual :

MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. (This does not occur for other types such as DATETIME.) By default, the current time zone for each connection is the server's time. The time zone can be set on a per-connection basis. As long as the time zone setting remains constant, you get back the same value you store. If you store a TIMESTAMP value, and then change the time zone and retrieve the value, the retrieved value is different from the value you stored. This occurs because the same time zone was not used for conversion in both directions. The current time zone is available as the value of the time_zone system variable. For more information, see Section 9.6, “MySQL Server Time Zone Support”.

所以答案是:时间戳

关于MySQL存储不同时区的播放列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10007046/

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