Skip to content

Commit 2a63810

Browse files
authored
Merge pull request #8668 from kenjis/docs-time
docs: small improvements to Time
2 parents 1046de8 + db187b2 commit 2a63810

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

user_guide_src/source/libraries/time.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ extension's features to convert times across timezones and display the output co
77
is the ``Time`` class and lives in the ``CodeIgniter\I18n`` namespace.
88

99
.. note:: Since the Time class extends ``DateTimeImmutable``, if there are features that you need that this class doesn't provide,
10-
you can likely find them within the `DateTimeImmutable <https://www.php.net/manual/en/class.datetimeimmutable.php>`_ class itself.
10+
you can likely find them within the `DateTimeImmutable`_ class itself.
11+
12+
.. _DateTimeImmutable: https://www.php.net/manual/en/class.datetimeimmutable.php
1113

1214
.. note:: Prior to v4.3.0, the Time class extended ``DateTime`` and some inherited methods changed
1315
the current object state. The bug was fixed in v4.3.0. If you need the old Time class for backward
@@ -24,10 +26,11 @@ Instantiating
2426
There are several ways that a new Time instance can be created. The first is simply to create a new instance
2527
like any other class.
2628

27-
When you do it this way, you can pass in a string representing the desired time. This can
28-
be any string that PHP's `strtotime()`_ function can parse:
29+
When you do it this way, you can pass in a string representing the desired time.
30+
This can be any string that PHP's `DateTimeImmutable`_ constructor can parse. See
31+
`Supported Date and Time Formats`_ for details.
2932

30-
.. _strtotime(): https://www.php.net/manual/en/function.strtotime.php
33+
.. _Supported Date and Time Formats: https://www.php.net/manual/en/datetime.formats.php
3134

3235
.. literalinclude:: time/001.php
3336

user_guide_src/source/libraries/time/001.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
use CodeIgniter\I18n\Time;
44

5-
$myTime = new Time('+3 week');
5+
$myTime = new Time('2024-01-01');
6+
$myTime = new Time('2024-01-01 12:00:00');
67
$myTime = new Time('now');
8+
$myTime = new Time('+3 week');

0 commit comments

Comments
 (0)