调用Facebook PHP SDK时的日期时间和时区


DateTime and time zones when calling Facebook PHP SDK?

我的时区是Europe/Rome。我正在使用Facebook PHP SDK,API的洞察部分接受相对于太平洋夏令时的参数end_time

收集度量的时间段的结束,表示为unix时间(应该始终是午夜,太平洋夏令时)。

问题很简单:在调用getTimeStamp()之前,我是否应该将$end转换为PDT(以及如何转换),以便获得我所在时区的正确统计数据?

// Get stats with 1st January 2012 as end_time (relative to my time zone)
$page  = Facebook->getUser()->getPage($id);
$stats = $page->getData('page_views_unique', new DateTime('2012-01-01')); 
public function getData($metric, DateTime $end = null)
{
   $now = new DateTime();
   $end = is_null($end) || $end > $now ? $now : $end; // Default is $now
   // API call
   $args = array('end_time' => $end->getTimestamp());
   $this->sdk->api(sprintf('/%s/insight/%s', $this->id, $metric), 'GET', $args);
}

在PHP 中将时间和日期从一个时区转换为另一个时区

<?php
$date = new DateTime('2000-01-01', new DateTimeZone('Europe/Rome'));
echo $date->format('Y-m-d H:i:sP') . "'n";
$date->setTimezone(new DateTimeZone('America/Los_Angeles'));
echo $date->format('Y-m-d H:i:sP') . "'n";
?>