Are unix timestamps the best way to store timestamps?

后端 未结 9 880
梦毁少年i
梦毁少年i 2020-12-07 16:26

I always use unix timestamps for everything, but am wondering if there is a better way.

What do you use to store timestamps and why?

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 16:57

    A timestamp is not a good idea on databases, because they do not take daylight savings or the current local time into account. On MySQL it is better to store it as a time, and then use the MySQL date and time functions to retreive the parts you want, or compare to other dates.

提交回复
热议问题