Re: Wrong time being displayed by PHP!

From: Date: Tue, 16 Oct 2012 22:16:20 +0000
Subject: Re: Wrong time being displayed by PHP!
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-319494@lists.php.net to get a copy of this message
On Oct 16, 2012 5:24 PM, "Richard S. Crawford" <rscrawford@mossroot.com> wrote: > > Sorry about that. I was getting very frustrated with the issue, and I forgot. I'll be sure to keep it in mind. No worries. >> >> With regard to debugging your issue, it's extremely unlikely that >> it's PHP's fault, since no one else has the same issue. However, it >> does indeed sound as though there's a configuration mismatch or a bad >> setting of the system clock (as suggested earlier by myself and >> others). What's the output when you run the code below? >> >> <?php >> >> if (php_sapi_name() == 'cli') { >> define('NL',PHP_EOL); >> } else { >> define('NL','<br/>'.PHP_EOL); >> } >> >> echo date_default_timezone_get().NL; >> >> echo date('r').NL; >> >> echo gmdate('r').NL; >> >> echo time().' ('.date('Z').')'.NL; >> >> echo trim(date).NL; >> >> ?> > > > This is the output: > > America/Los_Angeles > Tue, 16 Oct 2012 17:22:09 -0400 > Tue, 16 Oct 2012 21:22:09 +0000 > 1350422529 (-14400) > Tue Oct 16 17:22:09 EDT 2012 Is this a shared server, Rich? As shown, the admin configured the timezone of the machine to be EDT and set the clock right, but php.ini must be set to PDT. You can easily override this with a local php.ini file, an .htaccess directive, or by placing date_default_timezone_set() near the top of the code.

« previous php.general (#319494) next »