As with many web apps, the app I'm developing should work with timezone conversion for our esteemed end users. However, since I was working with Carbon / DateTime in PHP 5.3, I found this strange:
$date_str = '2014-04-15 12:00:00';
$date = new DateTime($date_str,new DateTimeZone('GMT'));
$date->setTimezone(new DateTimeZone('Etc/GMT+5'));
echo $date->format('Y-m-d H:i:s O');
I set the time zone $dateto GMT + 5, but when I format $date, it becomes -0500instead of the expected one +0500.
Similarly, if I set it to negative, i.e. Etc/GMT-5, format shows +0500instead of expected -0500.
Anyone who can educate?
I was able to replicate this problem in PHP 5.3.3, 5.3.13, 5.3.28. Thought it was a bug of the PHP-specific version. Error or function?