2012-01-16 68 views
2

我的時區爲Europe/Rome。我使用PHP Facebook的SDK和API的insights部分接受一個參數end_time相對於Pacific Daylight Time調用Facebook PHP SDK時的日期時間和時區?

在此期間收集的指標的時間段的結束, 表示爲UNIX時間(應永遠是午夜,太平洋 夏令時)。

問題是公平的簡單:我應該爲了得到我的時區正確的統計調用getTimeStamp()之前轉換$end光動力治療(以及如何)?

// 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); 
} 

回答