Configure timezone in dockerized Nginx + PHP-FPM Configure timezone in dockerized Nginx + PHP-FPM nginx nginx

Configure timezone in dockerized Nginx + PHP-FPM


There are two type of Time zone settings. One is a system level. That you can set using /etc/localtime

See the Dockerfile steps below

ENV TZ=America/Los_AngelesRUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

PS: Taken from https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes

Also you can refer to another article Using docker-compose to set containers timezones

Next is the PHP/APP level setting. For that you can create a ini file. Which can be done by adding below line to Dockerfile

RUN printf '[PHP]\ndate.timezone = "US/Central"\n' > /usr/local/etc/php/conf.d/tzone.ini