[prev in list] [next in list] [prev in thread] [next in thread]
List: php-general
Subject: Re: echo strftime('%s'); returns -1, should be epoch time
From: "Christoph M. Becker" <cmbecker69 () gmx ! de>
Date: 2020-06-09 7:49:03
Message-ID: d947d327-0132-83dc-5069-e458eb867776 () gmx ! de
[Download RAW message or body]
On 08.06.2020 at 19:55, Pete Cooper wrote:
> Hello.
> I'm compiling PHP 7.4 and 7.3 from source on a self-managed Ubuntu 20.04 server. I \
> am encountering an issue with obtaining the epoch time.
> This is the command I am using:
>
> php -r "echo strftime('%s');"
>
> I expect the above to return epoch time (i.e. 1591628404 or thereabouts), but \
> instead it returns -1.
> In my testing, running the above command on a vanilla Ubuntu LTS release with \
> maintained `apt` packages returns the expected result.
> I am scratching my head about the configuration/compile differences between the \
> working and non-working instances. It's not clear to me whether the issue is with \
> PHP compile/config setup, or operating system locale differences, or something else \
> entirely. I am grateful for any advice or feedback.
PHP's strftime() is implemented on top of strftime(3) which is rather
system specific; the %s modifier isn't even required by POSIX[1].
I would just use time() instead.
[1]
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>
--
Christoph M. Becker
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic