I have a unix timestamp that is set to +5, but I'd like to convert it to -5, EST Standard time. I would just make the time stamp be generated in that time zone, but I'm grabbing it from another source which is putting it at +5.
Current Unmodified Timestamp Being Converted Into A Date
<? echo gmdate("F j, Y, g:i a", 1369490592) ?>
As because edit queue for John Conde's answer is full I'll add more detailed answer.
From
DateTime::__construct(string $time, DateTimeZone $timezone)
This is the main reason why you should always specify timezone, even default, when creating
DateTime
objects from unix timestamp. See explained code inspired by John Conde's answer:Use DateTime and DateTimeZone:
An easier way to do that is:
While using
gmdate()
, add your time zone in seconds to unix_stamp in gmdate.Consider my time zone is GMT+5:30. So 5 hr 30 min in seconds will be 19800
So, I'll do this:
gmdate("F j, Y, g:i a", 1369490592+19800)