0
我有以下代码:碳时区功能是不正确
// $this->date_from = '11/01/2017';
// $this->date_to = '11/30/2017';
$this->where_date_from = Carbon::parse($this->date_from)->tz('America/Toronto')->startOfDay()->timestamp;
$this->where_date_to = Carbon::parse($this->date_to)->tz('America/Toronto')->endOfDay()->timestamp;
这产生完全innacturate时间戳。它似乎实际上是从UTC减去了两倍的偏移量。
然而,当我使用以下命令:
date_default_timezone_set('America/Toronto');
$this->where_date_from = strtotime($this->date_from.' 00:00:00');
$this->where_date_to = strtotime($this->date_to.' 23:59:59');
它完美。
这是怎么发生的?我想用碳来达到这个目的,所以我不必与date_default_timezone_set
混淆。