Skip to content

Commit 90dda25

Browse files
committed
docs: Correct the explanation of now()
To be honest, I don't understand the behavior of this function. The UNIX timestamp has nothing to do with time zone.
1 parent f9f606d commit 90dda25

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

user_guide_src/source/helpers/date_helper.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@ The following functions are available:
2929
:returns: UNIX timestamp
3030
:rtype: int
3131

32-
Returns the current time as a UNIX timestamp, referenced either to your server's
33-
local time or any PHP supported timezone, based on the "time reference" setting
34-
in your config file. If you do not intend to set your master time reference to
35-
any other PHP supported timezone (which you'll typically do if you run a site
36-
that lets each user set their own timezone settings) there is no benefit to using
37-
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()``.
3835

3936
.. literalinclude:: date_helper/002.php
4037

41-
If a timezone is not provided, it will return ``time()`` based on the
42-
**time_reference** setting.
38+
If any PHP supported timezone is provided, it will return a timestamp that is off 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.
4344

4445
.. php:function:: timezone_select([$class = '', $default = '', $what = \DateTimeZone::ALL, $country = null])
4546
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)