我希望能够根据我当前所在的时区来提取数据。
例如,我现在有这个问题:
$response = $fb->get('/pageid/insights/page_impressions?period=day')
我收到了这个回复:
但是我将如何显示数据以使其为Eastern Time (ET)
格式。也称为EDT
或UTC -4
?我假设它是一个额外的“参数”添加到查询中,但它会是什么?
答案 0 :(得分:1)
Unfortunately, you can't. All data is aggregated by days according to a fixed offset of UTC-7 (even when the Pacific time zone is on UTC-8).
You could adjust the time zone of the resulting timestamp, but that would be misleading, as the value
totals would now not truly be matching the days total for the time zone specified.
Really, an API like this (or any operation grouping timestamps by date) should consider a time zone - and that time zone should be specified by full IANA time zone identifier, such as America/New_York
. Consider that UTC-4 is not sufficient, because US Eastern Time alternates between EST (UTC-5) and EDT (UTC-4).
You could request Facebook add this feature, but AFAIK they do not currently offer it.
See also this related answer.