为什么 strtotime 会自动减去 2 小时?
Why strtotime subtracts 2 hours automatically?
我用了strtotime("YYYY-MM-DD H:i:s")
,这给了我一个自动减去2小时的时间。
例如:strtotime("2016-05-11 00:00")
给了我 int(1462917600)
这与我输入的内容相差 2 小时。
即:2016-05-10 22:00
当我重新转换时。
这是为什么?
来自docs:
Each parameter of this function uses the default time zone unless a time zone is specified in that parameter.
所以我猜你所在的时区是 2016-05-11 00:00:00 本地是 2016-05-10 22:00:00 UTC。
整数结果将总是在"seconds since the Unix epoch"中,它唯一地标识了一个瞬间。要将 转换为 或 从 转换,您应该考虑要使用的时区。
我用了strtotime("YYYY-MM-DD H:i:s")
,这给了我一个自动减去2小时的时间。
例如:strtotime("2016-05-11 00:00")
给了我 int(1462917600)
这与我输入的内容相差 2 小时。
即:2016-05-10 22:00
当我重新转换时。
这是为什么?
来自docs:
Each parameter of this function uses the default time zone unless a time zone is specified in that parameter.
所以我猜你所在的时区是 2016-05-11 00:00:00 本地是 2016-05-10 22:00:00 UTC。
整数结果将总是在"seconds since the Unix epoch"中,它唯一地标识了一个瞬间。要将 转换为 或 从 转换,您应该考虑要使用的时区。