将时间存储在数据库中

时间:2014-10-24 09:19:32

标签: php timezone

哪种方法可以存储来自整个世界的数据? 例如,我在考虑将time()存储在没有时区的情况下,然后每次都进行转换。

可能是对的?有没有办法检测请求的时区?

1 个答案:

答案 0 :(得分:0)

为此,您可以在数据库中保存 Unix时间戳

http://php.net/manual/en/function.time.php
http://dev.mysql.com/doc/refman/5.5/en/datetime.html

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

因此每个人都有相同的时间戳格式,没有时区。

否则,您必须存储日期时间字段和时区并计算正确的值。