katzgrau/KLogger

DateTime Fatal Error with PHP 5.6.11

Closed this issue ยท 6 comments

I get this error when I try to use Klogger:
"
PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): 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 vendor/katzgrau/klogger/src/Logger.php:307
"

It should still continue if I'm correct?

Adjust:
php.ini - Line 937 (or around there at least)
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Europe/Stockholm"

Uncomment the date.timezone line and set your timezone. That should get rid of the error for now.

This is caused because we're using a slightly outdated date() function in KLogger.

Yeah, was just googling around and saw that suggestion.
It did not contiue execution though. Fatal error in this case was very fatal.

But thanks, i'm implementing your adjustment now

No more errors or warnings.
Merci!

You must have had very strict errors on your php.ini config then ๐Ÿ‘ I can only applaud.

I got confused because the fatal error said:
We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.

Which means it SHOULD continue as it now obviously made the decision to choose UTC.

Anyway, glad it's resolved ๐Ÿ‘

@katzgrau Perhaps we should consider moving over to DateTime class. I can submit a PR for this tomorrow or Sunday ๐Ÿ‘

Hmm, true I guess.

Seems though that the DateTime::_construct() threw an exception even after it seemed to have picked UTC. I believe it was this uncaught exception that terminated the program

Actually now that I look further into it, it's caused by: Line-307 which is where we already use the DateTime class.

@teliov In order for me to replicate this, could you send me the parameters you sent into the constructor?

Did you send in a custom filename or did you let KLogger take care of this?

Because if you let KLogger take care of this, you should have already seen a warning because of Line-157