Re: Wrong time being displayed by PHP!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Oct 16, 2012 5:24 PM, "Richard S. Crawford" <rscrawford@xxxxxxxxxxxx>
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.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux