Re: date() confustion
| From: | Simon J Welsh | Date: | Thu, 26 Apr 2012 04:44:57 +0000 |
| Subject: | Re: date() confustion | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-317689@lists.php.net to get a copy of this message | ||
On 26/04/2012, at 4:40 PM, Nathan Nobbe wrote:
> Hi everyone,
>
> Does anybody know what might influence the output of the date() function
> besides date.timezone setting?
>
> Running through some code in an app I'm working on, I have this code:
>
> $timestamp = time();
> $mysqlDatetime = date("Y-m-d G:i:s", $timestamp);
>
> Logging these values yields:
>
> INSERT TIMESTAMP: 1335414561
> INSERT DATE TIME: 2012-04-26 4:29:21
>
> But then from the interactive interpreter on the same box (same php.ini as
> well):
>
> php > echo date("Y-m-d G:i:s", 1335414561);
> 2012-04-25 22:29:21
>
> I get this same output from another random computer of mine and I've
> verified date.timezone is consistent in both environments.
>
> Something's going on in the first case, but I'm unsure what; any ideas?
>
> Your help appreciated as always.
>
> -nathan
A call to date_default_timezone_set() during execution can change the timezone. If you add echo
date_default_timezone_get(); just before this, does it give the same output as your date.timezone
setting?
---
Simon Welsh
Admin of http://simon.geek.nz/