Docker Community Forums

I discovered Docker not longtime ago, that is exactly what i need to run applications on previous versions of PHP under Ubuntu.

I installed Dolibarr which is a commercial management PHP software, it is running but the pages are permanently polluted by dose of warning like this

`

> Warning: getdate(): 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 /var/www/html/dolibarr/htdocs/core/lib/functions.lib.php on line 1702

I searched a lot on this problem and i could find it is a problem of the timezone not set inside the container, i tried a lot of tries but nothing drove to success.

This is a PHP configuration thing - you need to specifically tell it what timezone you’re using because it doesn’t care about the system one. There are two ways to do this:

Method 1: Explicitly Set the Timezone in your PHP script

If you can edit your PHP code, you can simply add the following statement, before you start interacting with date functions:

date_default_timezone_set('UTC');

Method 2: Set the Timezone in the PHP Config

If you don’t want to / can’t edit your PHP files, and you want a more “overall” solution, you can just update the config in the box itself. Create a file in your project called something like “timezone.ini” which contains:

date.timezone=UTC

Then update your docker-compose to include it in the PHP config directory: