It appears from the CodeIgniter documentation that they are treating time zones as fixed offsets. Their convention is fairly straight forward:
So why did they do this? Who knows. It's not a standard thing, it's a CodeIgnitor special format. Normally an offset is just represented like +05:30
or +0530
.
Using an offset to represent a whole time zone is out of sync with reality. If it was that easy, then we wouldn't need the IANA time zones like Europe/Berlin
in the first place. You can see in the time zone list here that Europe/Berlin
alternates between +01:00 and +02:00. Code Ignitor might say that it is UP1
, but then that wouldn't ever take into account the daylight time offset. (Daylight saving time is different all over the world, so you can't just augment this with a checkbox and expect to be reliable.)
So, if you must have CodeIgnitor's strange form of time zone representation, then take the base offset of the IANA zone and apply their funky formula (as dev-null-dweller showed in his answer). Just don't expect it to be accurate.
And if you're in zone with a :45 offset, then you're out of luck. That would be Pacific/Chatham
or Asia/Kathmandu
.
You can read more in the timezone tag wiki under "Time Zone != Offset"
Just to add something actually constructive to to this answer, I recommend not using CodeIgnitor's time zones. Just stick with the IANA zones as provided for you by PHP. They are even kept up to date via timezondb in the PECL.