Timezone setting needed in OJS to stop errors flooding server log

My very good host administrator found that, with our newly-installed OJS 2.4.8 package, his web server’s error log was being flooded with the following message on every page access:

“Message: WARNING: strtotime(): 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.”

The culprit is /home/[… ]/public_html/plugins/generic/usageStats/UsageStatsLoader.inc.php

His kind solution was to modify my index.php file, adding the following line to the top of it:

date_default_timezone_set(’[country]/[city]’);

But as he points out, a generic timezone like UTC is going to be inaccurate for many OJS installations. Furthermore, many hosting providers, for good reason, do not allow individual custom php.ini files within the hosting environment.

This issue has been around for some time now (see It is not safe to rely on the system's timezone settings · Issue #821 · pkp/pkp-lib · GitHub).

Could we add our voices to those asking for an OJS programmatic solution?

Hi @job,

Does your host permit custom PHP configuration options using a .htaccess file? In my experience hosts generally permit this.

If your goal is simply to suppress the warnings, that’s what I’d recommend. If you have need for user-specific time zone settings, that’s a potential feature request, though not currently a high priority.

Regards,
Alec Smecher
Public Knowledge Project Team