My time zone is Europe/Rome
. I'm using Facebook PHP SDK and insights part of the API accepts a parameter end_time
relative to Pacific Daylight Time:
The end of the period during which the metrics were collected, expressed as a unix time (which should always be midnight, Pacific Daylight Time).
Question is fair simple: should i convert $end
to PDT (and how) before calling getTimeStamp()
in order to get correct stats for my time zone?
// 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);
}