Smarty 3.0 and PHP 5.3

96 views
Skip to first unread message

Karel S.

unread,
Oct 1, 2009, 5:12:21 AM10/1/09
to Smarty Developers
Warning: date_default_timezone_get(): 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 'Europe/Berlin' for 'CEST/2.0/DST' instead in /.../
Smarty.class.php on line 219

PHP 5.3 has a new approach to date functions. Perhaps it is possible
to keep this in mind?

Monte Ohrt

unread,
Oct 1, 2009, 9:35:19 AM10/1/09
to smarty-d...@googlegroups.com
Yes, set your default timezone in the php.ini.  :) This will happen with any of your PHP date/time funcs, not just Smarty. This has come up before, and the question is, is it Smarty's responsibility for you to set your PHP timezone? Not really.

Karel S.

unread,
Oct 1, 2009, 9:42:16 AM10/1/09
to Smarty Developers
"Yes, set your default timezone in the php.ini. :) This will happen
with any
of your PHP date/time funcs, not just Smarty."

Alright :)

"This has come up before, and the question is, is it Smarty's
responsibility for you to set your PHP timezone? Not really."

If Smarty is not responsibility, why call date_default_timezone_set ()
on line 219 ?

David Ramalho

unread,
Oct 1, 2009, 9:45:02 AM10/1/09
to smarty-d...@googlegroups.com


"This has come up before, and the question is, is it Smarty's
responsibility for you to set your PHP timezone? Not really."

If Smarty is not responsibility, why call date_default_timezone_set ()
on line 219 ?

wrong approach :) Smarty will call all available functions as it requires them, Smarty will/should _not_ setup your environment *for* you :)

the only reason that message creeps up is because the environment (php.ini for instance) is not properly setup :) , not simply because smarty is calling this or that function



up up and away :)
David 

Monte Ohrt

unread,
Oct 1, 2009, 12:15:12 PM10/1/09
to smarty-d...@googlegroups.com
On Thu, Oct 1, 2009 at 8:42 AM, Karel S. <ka...@hardware.info> wrote:

"Yes, set your default timezone in the php.ini.  :) This will happen
with any
of your PHP date/time funcs, not just Smarty."

Alright :)

"This has come up before, and the question is, is it Smarty's
responsibility for you to set your PHP timezone? Not really."

If Smarty is not responsibility, why call date_default_timezone_set ()
on line 219 ?


So it looks like Smarty does try to set the timezone. You still get the error even when smarty calls date_default_timezone_set () for you?
 

Monte Ohrt

unread,
Oct 1, 2009, 12:15:48 PM10/1/09
to smarty-d...@googlegroups.com
On Thu, Oct 1, 2009 at 8:42 AM, Karel S. <ka...@hardware.info> wrote:

"Yes, set your default timezone in the php.ini.  :) This will happen
with any
of your PHP date/time funcs, not just Smarty."

Alright :)

"This has come up before, and the question is, is it Smarty's
responsibility for you to set your PHP timezone? Not really."

If Smarty is not responsibility, why call date_default_timezone_set ()
on line 219 ?



So Smarty does try to set that for you? And you still get an error?
 

Monte Ohrt

unread,
Oct 1, 2009, 12:23:37 PM10/1/09
to smarty-d...@googlegroups.com
I stand corrected, Smarty does its best to tell PHP to get that set in the constructor:

        if (function_exists("date_default_timezone_set")) {
date_default_timezone_set(date_default_timezone_get());
}

This will safely leave the current setting alone, or try to set it according to the methods that date_default_timezone_get() uses.

So you say that you still get a warning with that in place? Is your timezone setting wrong in php.ini ?

Monte Ohrt

unread,
Oct 1, 2009, 12:28:36 PM10/1/09
to smarty-d...@googlegroups.com
I see, PHP changed it's warning messages. Now it complains if you use date_default_timezone_get() at all. The moral of the story: use date.timezone in php.ini to set your timezone, do not rely on system values. Maybe this should be removed from the constructor.

Monte Ohrt

unread,
Oct 1, 2009, 12:37:58 PM10/1/09
to smarty-d...@googlegroups.com
Yes, I'm replying to myself again. We are removing this from the smarty constructor. The developer needs to set the timezone either in php.ini, or literally in the php script, ie. date_default_timezone_set('US/Central'); Smarty won't try to tell PHP to fix your problems anymore, as that now throws a warning. Thanks for bringing that to our attention :)

U.Tews

unread,
Oct 1, 2009, 1:11:07 PM10/1/09
to Smarty Developers
timezone setting is removed now in the SVN

On Oct 1, 6:37 pm, Monte Ohrt <mo...@ohrt.com> wrote:
> Yes, I'm replying to myself again. We are removing this from the smarty
> constructor. The developer needs to set the timezone either in php.ini, or
> literally in the php script, ie. date_default_timezone_set('US/Central');
> Smarty won't try to tell PHP to fix your problems anymore, as that now
> throws a warning. Thanks for bringing that to our attention :)
>
> On Thu, Oct 1, 2009 at 11:28 AM, Monte Ohrt <mo...@ohrt.com> wrote:
> > I see, PHP changed it's warning messages. Now it complains if you use
> > date_default_timezone_get() at all. The moral of the story: use
> > date.timezone<http://us2.php.net/manual/en/datetime.configuration.php#ini.date.time...>in php.ini to set your timezone, do not rely on system values. Maybe this
Reply all
Reply to author
Forward
0 new messages