# PHP: (bizarre bug) Setting 'error reporting' breaks date/time support



## ghostcorps (Dec 18, 2012)

Hi Guys,

 I have recently come across a very odd issue with my webserver.

 For some background I am configuring Newznab to run on my webserver: www/apache22, lang/php5, databases/mysql51-server. There are a few things I need to tinker with to make it work but in the meantime I seem to have uncovered a very bizarre bug.

 Currently I have the date.time in php.ini set as follows:

/usr/local/etc/php.ini

```
[Date]

; Defines the default timezone used by the date functions
; http://php.net/date.timezone
[color="Red"]date.timezone = Europe/Berlin[/color]
```

This works fine and when I view the info.php page I see:


> *Date*
> date/time support: enabled
> "Olson" Timezone Database Version: 2012.8
> Timezone Database: internal
> Default timezone: Europe/Berlin




However...

For (I suspect) unrelated reasons with Newznab I have to change the error reporting to the following:

/usr/local/etc/php.ini

```
; error_reporting
;   Default Value: E_ALL & ~E_NOTICE
[color="Red"]   Development Value: E_ALL | E_STRICT[/color]
;   Production Value: E_ALL & ~E_DEPRECATED
```

Which should be fine, however after doing this the date/timezone functionality is broken resulting in the following error printing all over and page using lang/php5, whether it is related to Newznab or not:



> 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 methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in _*/PATH/FILE*_.php on line *#*



This error also appears in the Date section of the info.php page and the timezone is also altered from that which is set in php.ini:


http://www.domain.ino.php


> *Date*
> 
> 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 methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /usr/local/www/apache22/data/info.php on line 4
> 
> ...




What could possibly be causing this?


----------



## usdmatt (Dec 18, 2012)

Have you actually uncommented that 'Development Value' line in /usr/local/etc/php.ini (removed the semicolon)?


----------



## ghostcorps (Dec 19, 2012)

usdmatt said:
			
		

> Have you actually uncommented that 'Development Value' line in /usr/local/etc/php.ini (removed the semicolon)?



Yes, without uncommenting it there is no issue.


----------



## usdmatt (Dec 19, 2012)

That line is supposed to be a comment. Those lines just give suggested values for different purposes. I suspect by uncommenting that you've corrupted the ini file, causing php to ignore it, hence the timezone goes back to default.

Leave that line commented out. There should be another line further down where the error_reporting value is actually set. It's that line which needs adjusting to E_ALL | E_STRICT.


----------



## ghostcorps (Dec 19, 2012)

usdmatt said:
			
		

> That line is supposed to be a comment. Those lines just give suggested values for different purposes. I suspect by uncommenting that you've corrupted the ini file, causing php to ignore it, hence the timezone goes back to default.
> 
> Leave that line commented out. There should be another line further down where the error_reporting value is actually set. It's that line which needs adjusting to E_ALL | E_STRICT.



After spending so much time formatting my post could I be this dumb!!?


Yes... You were 100% right I had two error reporting lines in the php.ini.

However, after recommenting the example and changing the existing value as so:


/usr/local/etc/php.ini

```
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Error handling and logging ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

...

E_ALL | E_STRICT
```

The results are still the same. I also cleared my browser cache to be sure.



Thanks for figuring that bit out though, it would have caused no end to the headaches.


----------



## ghostcorps (Dec 19, 2012)

Furthermore: It seems that the Default, Development & Production examples will all cause the issue. I have to leave no value for the Time/Date to work.


----------



## Wiedmann (Dec 19, 2012)

ghostcorps said:
			
		

> /usr/local/etc/php.ini
> 
> ```
> ; error_reporting
> ...


That's the wrong place to change this value. That's just an overview of different default values in different php.ini's (part of the source code)

You have to change the line which starts with:

```
error_reporting = ...
```
to whatever you want. It's the first directive in the error handling and logging section.


----------



## ghostcorps (Dec 19, 2012)

Wiedmann said:
			
		

> You have to change the line which starts with:
> 
> ```
> error_reporting = ...
> ```



I know this is going to sound super dumb, but that was not in the examples in the php.ini.

All good now 


Thanks guys


----------

