Skip to content

Commit 799d655

Browse files
authored
Merge pull request #6426 from kenjis/fix-docs-date_helper
docs: update date helper
2 parents e686a14 + 1621263 commit 799d655

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

user_guide_src/source/helpers/date_helper.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ dates.
99
:local:
1010
:depth: 2
1111

12+
.. note:: Many functions previously found in the CodeIgniter 3 ``date_helper`` have been moved to the :doc:`Time <../libraries/time>` class in CodeIgniter 4.
13+
1214
Loading this Helper
1315
===================
1416

@@ -27,17 +29,18 @@ The following functions are available:
2729
:returns: UNIX timestamp
2830
:rtype: int
2931

30-
Returns the current time as a UNIX timestamp, referenced either to your server's
31-
local time or any PHP supported timezone, based on the "time reference" setting
32-
in your config file. If you do not intend to set your master time reference to
33-
any other PHP supported timezone (which you'll typically do if you run a site
34-
that lets each user set their own timezone settings) there is no benefit to using
35-
this function over PHP's ``time()`` function.
32+
.. note:: It is recommended to use the :doc:`Time <../libraries/time>` class instead. Use ``Time::now()->getTimestamp()`` to get the current UNIX timestamp.
33+
34+
If a timezone is not provided, it will return the current UNIX timestamp by ``time()``.
3635

3736
.. literalinclude:: date_helper/002.php
3837

39-
If a timezone is not provided, it will return ``time()`` based on the
40-
**time_reference** setting.
38+
If any PHP supported timezone is provided, it will return a timestamp that is offset by the time difference. It is not the same as the current UNIX timestamp.
39+
40+
If you do not intend to set your master time reference to
41+
any other PHP supported timezone (which you'll typically do if you run a site
42+
that lets each user set their own timezone settings) there is no benefit to using
43+
this function over PHP's ``time()`` function.
4144

4245
.. php:function:: timezone_select([$class = '', $default = '', $what = \DateTimeZone::ALL, $country = null])
4346
@@ -48,11 +51,8 @@ The following functions are available:
4851
:returns: Preformatted HTML select field
4952
:rtype: string
5053

51-
Generates a `select` form field of available timezones (optionally filtered by `$what` and `$country`).
54+
Generates a `select` form field of available timezones (optionally filtered by ``$what`` and ``$country``).
5255
You can supply an option class to apply to the field to make formatting easier, as well as a default
5356
selected value.
5457

5558
.. literalinclude:: date_helper/003.php
56-
57-
Many functions previously found in the CodeIgniter 3 ``date_helper`` have been moved to the ``I18n``
58-
module in CodeIgniter 4.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
echo now('Australia/Victoria');
3+
echo now();

0 commit comments

Comments
 (0)