How can I make Ubuntu automatically detect the correct timezone based on my internet connection?

My default location is GMT+1. I would like Ubuntu to automatically change my default timezone based on the timezone of my connected internet connection.

Example:

When I am in Portugal, and connected to an internet connection, I want Ubuntu to change my timezone setting from GMT+1 to GMT+0.

Moreover, I ensured that the following settings are set but they do not make my timezone change:

enter image description here

enter image description here


There is a script in GitHub to detect and update the current time zone, using geolocation from your IP address: https://github.com/cdown/tzupdate

Once python and python-pip are installed, the script can be installed as:

pip install -U tzupdate

And run as

sudo ~/.local/bin/tzupdate

This command could be somehow automatically run on startup.


For Ubuntu 18.04 make sure Settings -> Privacy -> Location Services is set to "On."

Solution provide by glortho Auto Timezone doesn't update

It automatically works right away.