Reputation: 827
quick question. I'm working with the Instagram API and everything I'm getting from their response seems to be pacific timezone. Now, I'd like to save this data to a use and display it to visitors. Problem is, visitor may be from all different timezones. So should I convert this to unix timestamp to GMT, then on display, use some sort of javascript or PHP to convert the unix timestamp to a user friendly, timezone adjust date time?
If so, my two questions are... how would I convert a timestamp in PST timezone to GMT and the how would I display that to users from different timezones? Thanks!
Upvotes: 1
Views: 1384
Reputation: 1
You can do this by using DateTime in php to calculate the offset that you will need to convert from one time zone to another. See http://blog.serverdensity.com/2009/03/21/handling-timezone-conversion-with-php-datetime/
Upvotes: 0
Reputation: 496
You can create a couple TimeZone objects and then create the DateTime object in the correct timezone the convert
$pdtTimezone = new DateTimeZone('America/Los_Angeles');
$userTimeZone = new DateTimeZone(whatever_you_need);
$orig_date_obj = new DateTime( time_to_convert , $pdtTimezone) ;
$orig_date_obj->setTimeZone($usertimezone);
Upvotes: 2