0

I use Instagram API and there is one important field there, created_time. And those are in Unix timestamp format. I convert it to datetime with date('Y-m-d H:i:s',$insta_date); (PHP) And it gives me normal datetime with GMT+0. But i want it with GMT+3. Is there any shortest way to get GMT+N datetime from Unix timestamp?

4

2 回答 2

2

您可以将时间更改为不同的时区。PHP函数是:

date_default_timezone_set()

更多信息: http: //php.net/manual/en/function.date-default-timezone-set.php

于 2013-06-05T14:48:11.400 回答
1

您可以使用gmdate获取格林威治标准时间,然后添加偏移量:

$offset = 3*60*60;    // +3 hours
gmdate('Y-m-d H:i:s', $insta_date+$offset)

如果date_default_timezone_set正确,您还可以使用date来格式化本地时间/日期。

于 2013-06-05T14:48:59.823 回答