Welcome Guest, Not a member yet? Register   Sign In
Use of unix_to_human() method generates PHP errors

Hi guys,

I'm new to CI and I wanted to use Date Helper. I first load the helper then try to use some methods like

PHP Code:

PHP Code:
var_dump(unix_to_human(now(), TRUE'eu')); 

The first method worked well, the second one too, but with a lot of PHP errors (see attached file).

Error messages tell that

Quote:Message: date(): 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.

I'm currently using MAMP to develop and CI time_reference is set to 'local'. I change it to 'Europe/Paris' but still got the errors; then I passed timezone to the now() method :

PHP Code:
var_dump(unix_to_human(now('Europe/Paris'), TRUE'eu')); 

with same result (that is errors...). Finally I used PHP date_default_timezone_set() method :

PHP Code:
var_dump(unix_to_human(now(), TRUE'eu')); 

And it worked without any error!?

I wonder why this method is mandatory in that case ; I see no information about it in CodeIgniter manual!?

Thank you for any help

Attached Files Thumbnail(s)


(This post was last modified: 06-22-2016, 09:21 AM by ciadmin.)

This is a PHP thing - the default timezone needs to be set in php.ini (preferred), or manually in your code before using any of the date/time functions.

"PHP 5.3 now requires that you either have a timezone set in your php.ini file or that you pass the desired timezone via the date_default_timezone_set() function before calling the date() function."

Theme © iAndrew 2016 - Forum software by © MyBB