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.
This commit is contained in:
kenjis 2022-08-26 14:29:35 +09:00
parent f9f606da65
commit 90dda258e5
No known key found for this signature in database
GPG Key ID: BD254878922AF198
2 changed files with 10 additions and 9 deletions

View File

@ -29,17 +29,18 @@ The following functions are available:
:returns: UNIX timestamp
:rtype: int
Returns the current time as a UNIX timestamp, referenced either to your server's
local time or any PHP supported timezone, based on the "time reference" setting
in your config file. If you do not intend to set your master time reference to
any other PHP supported timezone (which you'll typically do if you run a site
that lets each user set their own timezone settings) there is no benefit to using
this function over PHP's ``time()`` function.
.. note:: It is recommended to use the :doc:`Time <../libraries/time>` class instead. Use ``Time::now()->getTimestamp()`` to get the current UNIX timestamp.
If a timezone is not provided, it will return the current UNIX timestamp by ``time()``.
.. literalinclude:: date_helper/002.php
If a timezone is not provided, it will return ``time()`` based on the
**time_reference** setting.
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.
If you do not intend to set your master time reference to
any other PHP supported timezone (which you'll typically do if you run a site
that lets each user set their own timezone settings) there is no benefit to using
this function over PHP's ``time()`` function.
.. php:function:: timezone_select([$class = '', $default = '', $what = \DateTimeZone::ALL, $country = null])

View File

@ -1,3 +1,3 @@
<?php
echo now('Australia/Victoria');
echo now();