Jump to content


Photo

Times Reported By Server In Php Don't Recognise Dst


  • Please log in to reply
3 replies to this topic

#1 sylvest

sylvest

    Distant Family

  • Members
  • PipPipPip
  • 101 posts

Posted 06 April 2017 - 11:42 AM

Hi,

The web pages that I am currently writing (in PHP) report errors including a timestamp to the file /home/xxxxxxx/logs/main.log. The times reported are UTC. I have the following in my PHP:
date_default_timezone_set("Europe/London");
which I believe should set it to use the stated timezone throughout my site, which should (I think) recognise DST, so should now report UTC +01:00. It is not doing so.
I thave changed the PHP code that writes to the log file to this:
$logmsg = gmdate("[d-M-Y H:i:s e I P T] ") . "on " . $hostname . " " ....
and it is now outputting:
[06-Apr-2017 16:19:50 UTC 0 +00:00 GMT] on localhost L_TRACE  at line 96 ....

from which you can see that it thinks it is outputting UTC. I think the problem is that it is just not switching to the timezone I have requested.

Please can you suggest why it is not outputting GMT/DST, i.e. UTC +01:00, or what I need to do to find out what is causing this problem?

Thank you - Rowan
 


Edited by TCH-Bala, 07 April 2017 - 06:54 PM.
edited out username


#2 TCH-Bryan

TCH-Bryan

    Distant Family

  • Staff
  • PipPipPip
  • 103 posts

Posted 06 April 2017 - 09:07 PM

Hi Rowan,

 

 

This issue should now be resolved. Your local version of php.ini (/home/USERNAME/php.ini) was overriding the date_default_timezone_set function. I have changed date.timezone value in that file to  "Europe/London". Could you please try again and let me know if the problem persists?
 


Bryan Abraham
Lead Administrator Assistant
Technical Support
TotalChoice Hosting, Inc
bryan@totalchoicehosting.com

AIM :: tchgurubryan
Yahoo :: tchgurubryan

#3 sylvest

sylvest

    Distant Family

  • Members
  • PipPipPip
  • 101 posts

Posted 10 April 2017 - 07:00 AM

Bryan,

 

Thanks for your help with this. Now the system error log is reporting the correct time in GMT with DST, but the PHP log is still reporting GMT without DST. I have removed all the calls to date_default_timezone_set() in my PHP files but it is still the same. To generate the PHP log my code is:

        $logmsg = gmdate("[d-M-Y H:i:s e I P T] ") . "on " . $hostname . " " . $loglevels[$level] . " " . $msg . " at line " . $line . " in file " . $file . PHP_EOL;
 

The text produced in the log file is (example):

        [10-Apr-2017 11:47:18 UTC 0 +00:00 GMT] on localhost L_TRACE Redirecting to Location: http://www.sylvester...oir/welcome.php using header at line 302 in file /home/xxx/include/initialise.php
 

Any idea why it is doing this, or what I can do to correct it?

 

Please can you explain how the date.timezone = in the PHP.ini file interacts with the date_default_timezone_set() in a PHP file. Does one override the other? Which takes precedence? Or if I use one, does using the other cause an error? Which way round?

 

Ideally I would like the PHP file to determine which timezone it uses, if necesary overriding what is written in the PHP.ini file, since one section of the web site may require a different timezone than another. Or I may want to reflect the timezone of the particular user that has logged on.

 

Thanks - Rowan


Edited by TCH-Bala, 10 April 2017 - 07:47 PM.
Please do not add sensitive information like domain and home directory paths on a public forum


#4 TCH-Bala

TCH-Bala

    Technical Support Manager

  • Staff
  • PipPipPipPip
  • 1,780 posts

Posted 10 April 2017 - 07:51 PM

Scripts default to the php parameters including timezone as set on the server's php.ini config. If you set a local php.ini (this needs to be set via cpanel -> MultiPHP INI Editor), then the default values will be overridden by what is set on the local ini file.


Balakrishnan
Manager - Technical Support
TotalChoice Hosting, Inc.
http://www.totalchoicehosting.com

TCH Help Desk .. || .. TCH Blog

Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users