Are unix timestamps the best way to store timestamps?

后端 未结 9 885
梦毁少年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:58

    UNIX Timestamp 32-bit problem seems to be pretty annoying for users who enter future dates in 2038+.

    Either use the DATETIME sequence for MySQL, or store your dates as BIGINT(8) unsigned (max: 18 quintillion) or FLOAT so that you can enter large numbers. Then you cannot use for example PHP's date() function because it only allows integers as parameter (limited by 32-bit systems).

    The solution I found is to use PHP 5.2.0 functions. Here's the DateTime PHP solution.

    No need to change UNIX_TIMESTAMP format. As long as you have BIGINT(8) unsigned as your MySQL storage for timestamps. You won't be limited by 32-bit systems anymore.

提交回复
热议问题