Description
Describe the bug
The native php DateTime::setTimezone() functions converts the time of object to the specified timezone, CI's Time Class which extends DateTime simply changes the Timezone without doing any conversion.
CodeIgniter 4 version
Current develop branch
Expected behavior, and steps to reproduce if appropriate
Consider the following code
$time = new \DateTime('13 May 2020 10:00 GMT');
$time->setTimeZone(new \DateTimeZone('GMT+1'));
This creates a new DateTime object with time 2020-05-13T10:00:00+00:00
and after conversion it becomes 2020-05-13T11:00:00+01:00
, the timezone changes and the time is converted to the new timezone.
Doing the same using CI's Time class
$time = new Time('13 May 2020 10:00 GMT');
$time = $time->setTimezone(new \DateTimeZone('GMT+1'));
Initially, this creates an object with time 2020-05-13T10:00:00+00:00
as well, after conversion however the object has time 2020-05-13T10:00:00+01:00
, the timezone changes but there is not conversion done. The time is 10:00AM in both instances
If this is the intended behaviour and not a bug should the docs be changed to reflect that? They currently say "Converts the time from it’s current timezone into the new one" which does not exactly describe what the function is doing.
Activity