I have a ISO8601 string with some arbitrary time zone. I don’t want to convert to my time zone. Rather, I want to preserve the original time zone. I want to be able to format the output similar to how gmdate formats the date/time. For example:
$output = my_date_function( 'F d, ga', $thetime );
Should output:
$thetime = '2012-09-24T21:00:00-0700';
=> September 24, 9pm
$thetime = '2012-09-24T21:00:00-0500';
=> September 24, 9pm
I don’t know if it would work but I think that DateTime::createFromFormat can do it automatically. You can also create a function that determine the timezone and create a DateTimezone object with it.
http://php.net/manual/en/datetime.createfromformat.php
According to the documentation :
Code: