Skip to content

Commit 3b51c3e

Browse files
committed
docs: add docs
1 parent 410635c commit 3b51c3e

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

user_guide_src/source/changelogs/v4.6.0.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,22 @@ Added check to prevent Auto-Discovery of Registrars from running twice. If it is
5757
executed twice, an exception will be thrown. See
5858
:ref:`upgrade-460-registrars-with-dirty-hack`.
5959

60-
.. _v460-interface-changes:
60+
Time::createFromTimestamp()
61+
---------------------------
62+
63+
``Time::createFromTimestamp()`` handles timezones differently. If ``$timezone``
64+
is not explicitly passed then the instance has timezone set to UTC unlike earlier
65+
where the currently set default timezone was used.
66+
See :ref:`Upgrading Guide <upgrade-460-time-create-from-timestamp>` for details.
6167

6268
Time with Microseconds
6369
----------------------
6470

6571
Fixed bugs that some methods in ``Time`` to lose microseconds have been fixed.
6672
See :ref:`Upgrading Guide <upgrade-460-time-keeps-microseconds>` for details.
6773

74+
.. _v460-interface-changes:
75+
6876
Interface Changes
6977
=================
7078

user_guide_src/source/installation/upgrade_460.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ See :ref:`ChangeLog <v460-behavior-changes-exceptions>` for details.
2929

3030
If you have code that catches these exceptions, change the exception classes.
3131

32+
.. _upgrade-460-time-create-from-timestamp:
33+
34+
Time::createFromTimestamp() Timezone Change
35+
===========================================
36+
37+
When you do not explicitly pass a timezone, now
38+
:ref:`Time::createFromTimestamp() <time-createfromtimestamp>` returns a Time
39+
instance with **UTC**. In v4.4.6 to prior to v4.6.0, a Time instance with the
40+
currently set default timezone was returned.
41+
42+
This behavior change normalizes behavior with changes in PHP 8.4 which adds a
43+
new ``DateTimeInterface::createFromTimestamp()`` method.
44+
45+
If you want to keep the default timezone, you need to pass the timezone as the
46+
second parameter::
47+
48+
use CodeIgniter\I18n\Time;
49+
50+
$time = Time::createFromTimestamp(1501821586, date_default_timezone_get());
51+
3252
.. _upgrade-460-time-keeps-microseconds:
3353

3454
Time keeps Microseconds

user_guide_src/source/libraries/time.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ This method takes a UNIX timestamp and, optionally, the timezone and locale, to
126126

127127
.. literalinclude:: time/012.php
128128

129-
.. note:: Due to a bug, prior to v4.4.6, this method returned a Time instance
130-
in timezone UTC when you do not specify a timezone.
129+
If you do not explicitly pass a timezone, it returns a Time instance with **UTC**.
130+
131+
.. note:: In v4.4.6 to prior to v4.6.0, this method returned a Time instance
132+
with the default timezone when you do not specify a timezone.
131133

132134
createFromInstance()
133135
====================

0 commit comments

Comments
 (0)