Nginx shows wrong time/timezone

Milano picture Milano · Dec 7, 2018 · Viewed 11.8k times · Source

How to fix Nginx timezone? I've configured nginx to serve a directory but datetime of creation is one hour after my real time.

I've added to /etc/init.d/nginx

export TZ='Europe/Bratislava'

then

sudo service nginx reload
sudo service nginx restart

But it didn't help, there should be 14:19 instead of 13:19.

EDIT

Tried to change Ubuntu default timezone but the datetimes aren't changed.

sudo dpkg-reconfigure tzdata

enter image description here

Answer

gpgekko picture gpgekko · Dec 7, 2018

By default, nginx outputs the directory index in UTC time. If you want it to display the time in your local timezone, you should set the autoindex_localtime directive to on.

autoindex_localtime on