The PHP DateTime object (and more specifically, the DateTimeZone object), supports many time zones. That is all nice and well, but is there a way to pass in a GMT offset as a time zone?
I know it’s possible to simply add or subtract hours and apply some math, but I was wondering whether there was a built-in, robust way of doing things (or do I need to make my own abstraction layer for this).
TL;DR How can I pass GMT+N values as time zones in PHP’s DateTime or DateTimeZone objects?
You can do this:
But there is this warning:
The list only supports whole hours. Some of your users may live in time zones that aren’t aligned by the hour. Also note that if users select a time via a UTC offset, they will have to change it twice a year during Daylight Saving / Summer Time. Selecting by location eliminates that need.