Re: [PHP] date() confustion

2012-04-26 Thread ma...@behnke.biz


Nathan Nobbe  hat am 26. April 2012 um 06:40
geschrieben:
>
> 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.
>

This definitly looks like a timezone offset!
Try the following code in your environments.

$date  = new  DateTime ( );
$tz  =  $date -> getTimezone ();
echo  $tz -> getName ();


PHP for CLI mode has a different php.ini than the one for apache2. Maybe
that is a problem?

Check also


php -i | grep "date.timezone"


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] date() confustion

2012-04-25 Thread Nathan Nobbe
On Wed, Apr 25, 2012 at 10:44 PM, Simon J Welsh  wrote:

> 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,

I was dumping out the value from ini_get('date.timezone'); seems it must be
getting set at runtime.

Thanks!

-nathan


Re: [PHP] date() confustion

2012-04-25 Thread Simon J Welsh
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/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] date() confustion

2012-04-25 Thread Nathan Nobbe
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