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?
Asked
Active
Viewed 3,290 times
0
-
3set your date locale? http://lu1.php.net/manual/en/function.date-default-timezone-set.php – bwoebi Jun 05 '13 at 14:35
-
Thanks bwoebi. :) I thought time() is only in GMT+0 and could not b formatted to other timezones. But it was not so. It worked with date_default_timezone_set("Zone/City");. – Elvin Haci Jun 05 '13 at 14:46
-
http://stackoverflow.com/questions/5454779/how-to-convert-php-date-formats-to-gmt-and-vice-versa – StampyCode Jun 05 '13 at 14:48
2 Answers
2
You can change the time to different timezone. The PHP function is:
date_default_timezone_set()
More info: http://php.net/manual/en/function.date-default-timezone-set.php

Charlie
- 11,380
- 19
- 83
- 138

Amar Banerjee
- 4,992
- 5
- 34
- 51
1
You can use gmdate to get Greenwich Mean Time, and then add offset:
$offset = 3*60*60; // +3 hours
gmdate('Y-m-d H:i:s', $insta_date+$offset)
You can also use date to format a local time/date, if date_default_timezone_set is correct.

Danijel
- 12,408
- 5
- 38
- 54