Re: Dates ahead of time on PHP
| From: | gordonisnz at gmail dot com | Date: | Sun, 07 May 2023 04:32:01 +0000 |
| Subject: | Re: Dates ahead of time on PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-328193@lists.php.net to get a copy of this message | ||
Which time zone is your server on? You may want to set your timezone before
requesting the current date.
Gordon
On Sun, 7 May 2023 at 15:44, <paulf@quillandmouse.com> wrote:
> I just upgraded my Debian OS, which updated me to PHP 8.2. Now, when I
> issue the following:
>
> $now = getdate(time());
> echo '<pre>';
> print_r($now);
> echo '</pre>';
>
> Here's what I get:
>
> Array
> (
> [seconds] => 47
> [minutes] => 34
> [hours] => 3
> [mday] => 7
> [wday] => 0
> [mon] => 5
> [year] => 2023
> [yday] => 126
> [weekday] => Sunday
> [month] => May
> [0] => 1683430487
> )
>
> I'm doing this on 6 May 2023 at about 23:39. Note that the date
> returned is on the *following* date, one day ahead of today.
>
> Here's what my system returns:
>
> $ date
> Sat May 6 11:39:41 PM EDT 2023
>
> This verifies that my system date is Saturday 6 May 2023. And yet PHP's
> date routines are returning 7 May 2023.
>
> So my question is, where is getdate(time()) getting its date
> information? And why isn't it using my system's date?
>
> Paul
>
> --
> Paul M. Foster
> Personal Blog: http://noferblatz.com
> Company Site: http://quillandmouse.com
> Software Projects: https://gitlab.com/paulmfoster
>
--
Gordon.