Adapt timezone for PHP worker on Heroku

Adapt timezone for PHP worker on Heroku

When working with custom timezones and Heroku, you have to make sure to add the timezone everywhere. I've published a post recently how to configure it for the web dyno and Postgres.

In usual hosted environments there is a php.ini file where you add the timezone and it's used everywhere. When using Heroku, you can add your own .user.ini file. But this is only used on executions of the web dyno. When you're using a worker like the Symfony messenger, you're using the php executable directly and need to pass INI directives through the -d command line option.

A worker definition in your Procfile might then look like this:

worker: php -d date.timezone='Europe/Berlin' bin/console messenger:consume async