Its raining timezone errors

For the past month and a half apparently, my MODX install has been generating “invalid date.timezone value”. This went un-noticed because the website has been preforming well and no errors showed on any page. It was noticed yesterday when we updated to 2.8.4 (had been 2.8.3 previously) and the error starting showing during the install process on the setup pages.

The primary error we are seeing is (from server error log in modx directory):

[07-Jun-2022 00:29:24 UTC] PHP Warning:  date(): Invalid date.timezone value 'UTC-4', we selected the timezone 'UTC' for now. in /path/to/core/xpdo/xpdo.class.php on line 2075

From the MODX error log just now:

[2022-06-07 00:39:47] (ERROR @ /path/to/core/model/smarty/sysplugins/smarty_internal_runtime_codeframe.php : 48) PHP warning: strftime(): Invalid date.timezone value 'UTC-4', we selected the timezone 'UTC' for now.

During the setup process the error messages mentioned other file names. But the same warning. And the update went ok.

My hosting provider doesn’t see anything wrong at their end and no changes were made around the time of the error start.

Any ideas what might be happening?

Environment

MODX 2.8.3 when error started showing, now MODX 2.8.4 still same error
PHP 7.4
Apache 2.4.53
No extras or custom modules
MySQL 5.7.38

Hey @mrcycling

I’m not an expert on this - but is “UTC-4” a valid timezone?

You could try adding line to your .htaccess file to specify your timezone, eg:

php_value date.timezone '*Region*/*Zone*'

You can find your Region / Zone here

@dejaya Yes one would expect “America/New York” not “UTC-4”. And that is part of the mystery, where is the value “UTC-4” coming from? The server is set to UTC.

You can check the setting in the php ini file via the Manager:

Manage > Reports > System Info

Then click “View” here:

image

Search that file for the string “timezone” … here’s what I see [I’m in Scotland]:

I think adding the line to your htaccess file will override these settings though.

There is also a system setting date_timezone in MODX to overwrite the server setting.

@dejaya The PHP Date timezone is America/New_York.

@halftrainedharry Thanks, setting that to America/New_York seems to have done the trick. Though I am still at a loss why the timezone would suddenly crop up as an issue. The website has been working just fine for ages.

1 Like

Was it actually visibly set to “UTC-4” in any of the locations?

@dejaya I can’t find the source of that value, nor can my hosting provider. Darn code ghosts

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.