NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
"It is not safe to rely on the system's timezone settin


Joined: 09 Aug 2010
Posts: 9
Reply with quote
I can't figure this out. Tried doing some searches and found a couple of other people who have experienced this, but no solution was provided. I installed PhpED with the debugger and everything seemed to install properly. However, when I try to run a simple script:

Code:

<?php
   phpinfo();
?>



I get the following error message:

"Error: E_WARNING
phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those method and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for '-4.0/DST' instead at test.php line 2"

Any thoughts? Thanks!
View user's profileFind all posts by hadoob024Send private message


Joined: 09 Aug 2010
Posts: 9
Reply with quote
OK. I figured out my error. Well, I don't know what caused it, but I just uncommented the following line:

Code:
date.timezone = "America/New_York"


Then restarted my webserver and it seems to work now.
View user's profileFind all posts by hadoob024Send private message


Joined: 11 Apr 2010
Posts: 90
Location: Prague, Czech Republic
Reply with quote
The E_WARNING is displayed if you use date/time function without setting the timezone (either in php.ini or in PHP script). I would suggest to set date/time setting on each PHP script using ini_set() function. This way you will be sure, that the timezone is correct everytime. Just put this simple line on the top of your main PHP file:
Code:
ini_set('date.timezone', 'America/New_York');
View user's profileFind all posts by fibizaSend private message


Joined: 09 Aug 2010
Posts: 9
Reply with quote
Thanks for the tip. Is there any advantage to doing this as opposed to setting the "date.timezone" field in php.ini?
View user's profileFind all posts by hadoob024Send private message


Joined: 11 Apr 2010
Posts: 90
Location: Prague, Czech Republic
Reply with quote
There is no difference on your local server. But you need to realize, that setting this in php.ini you are just configuring default settings for your local server. On the other hand setting this in PHP code, you are configuring server's environment on application's runtime. Realizing this, the advantage of setting it in PHP is that you set your own timezone on any server you deploy your application regardless the server's settings. Simply put, when you have this setting in PHP code, you do not need to care about server's configuration, which might be different or incorrect and your application will still run as you expect.
View user's profileFind all posts by fibizaSend private message


Joined: 09 Aug 2010
Posts: 9
Reply with quote
Makes sense. Thanks for the tip!
View user's profileFind all posts by hadoob024Send private message
"It is not safe to rely on the system's timezone settin
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic