GoAdmio

timezone

Set the timezone of the server and of PHP, either by name or detected automatically from your last login IP

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/timezone keeps the operating system and PHP on the same timezone. In one run it:

You can give a timezone name, or run the command with no arguments and let it detect one. Automatic detection uses the IP address of the most recent login to the server, not the server's own location.


Quick start

# Set a specific timezone
/go/timezone Europe/London

# Detect the timezone from the last login IP
/go/timezone

Syntax

/go/timezone [<timezone>]

Options

Argument Required Default Notes
<timezone> No Detected automatically A timezone name such as Europe/London or America/New_York. List the valid names with timedatectl list-timezones.

[!IMPORTANT] A timezone you pass is not checked before PHP is updated. A mistyped name (for example Londn) is written to the php.ini files, and only then rejected by timedatectl. The command still prints the success message, so check it carefully.


Output

With automatic detection, the command first prints what it found:

Country: GB
Timezone: Europe/London
Local timezone has been set to Europe/London.

With a timezone name, only the last line is printed (followed by any output from fpm).

Outcome What you get
Timezone set Local timezone has been set to <timezone>.
Detection failed Can't set time zone automatically. Exit status 1.
Unsupported OS Unknown operating system. Nothing is changed in PHP or the system.

Every run is logged to /var/log/go/timezone.log with a timestamp and the arguments used.


Examples

# Set the timezone to New York
/go/timezone America/New_York
# Set it to UTC
/go/timezone UTC
# Detect it from the last login
/go/timezone
# Find a valid name, then check the results
timedatectl list-timezones | grep -i dubai
timedatectl
php -i | grep date.timezone

Troubleshooting

Symptom Likely cause Fix
Can't set time zone automatically. ipinfo.io can't be reached or returned no timezone, or the last login wasn't from a public IP address (for example a console login). Pass the timezone name yourself.
The detected timezone is wrong The detection uses whoever logged in last, possibly through a VPN, or another administrator. Pass the timezone name yourself.
Unknown operating system. The OS isn't AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, or Ubuntu. Set the timezone by hand.
Failed to set time zone: Invalid time zone followed by "has been set" The name you passed isn't valid. Run the command again with a valid name. The php.ini files are overwritten the second time.
Permission denied when a php.ini is edited The command wasn't run as root. Run it as root.
PHP still shows the old timezone A site sets its own (in ini_set(), .user.ini, or a pool setting), a php.ini line has unusual spacing so it wasn't replaced, or PHP-FPM wasn't reloaded. Check the file with php -i, edit it by hand, and run /go/fpm --reload.
Database times didn't change Some services read the system timezone only when they start. Restart MariaDB.
A country was marked as whitelisted This happens the first time automatic detection runs. See Details. Review the list with your GoAdmio country settings.

Details

How it works

flowchart TD
    A["/go/timezone"] --> B{"Timezone given?"}
    B -- "No" --> C["Find the last login IP, look it up on ipinfo.io"]
    C --> D{"Found Area/City?"}
    D -- "No" --> X["Can't set automatically, exit 1"]
    D -- "Yes" --> E["Save the country on the first run"]
    B -- "Yes" --> F
    E --> F{"Supported OS?"}
    F -- "No" --> Y["Unknown operating system"]
    F -- "Yes" --> G["Update every php.ini"]
    G --> H["timedatectl set-timezone"]
    H --> I["Update the panel pool and timezone data"]
    I --> J["Reload PHP-FPM"]

Automatic detection

  1. Takes the IP address from the first line of last (the most recent login).
  2. Asks ipinfo.io about that IP and saves the answer to /usr/local/goadmio/tmp/ip.info.
  3. Reads the country and timezone from the answer. The timezone must contain a /, such as Europe/London, or detection fails.
  4. If /etc/country doesn't exist yet, writes the country code to it and sets Whitelist=1 for that country in /var/lib/sqlite/country.db.

Step 4 runs only once, the first time detection succeeds. It also happens before the OS check, so it can happen even if the OS turns out to be unsupported.

Detection sends the login IP address to the third-party service ipinfo.io.

PHP files updated

Only files that exist are edited.

OS Files
AlmaLinux, Rocky, CentOS, Red Hat, Fedora /etc/php.ini and /etc/opt/remi/<version>/php.ini for every installed version
Debian, Ubuntu /etc/php.ini and /etc/php/<version>/fpm/php.ini, cli/php.ini, and apache2/php.ini for every installed version

In each file:

Settings that a site makes itself (ini_set(), .user.ini, or its own pool) still override these values.

Other steps

  1. timedatectl set-timezone <timezone> sets the system timezone.
  2. /go/php-fpm go go updates the timezone of the panel's own PHP pool.
  3. /go/dst refreshes the timezone data.
  4. /go/fpm --reload "| Executed by timezone" reloads PHP-FPM.

Files and requirements

Item Used for
/usr/local/goadmio/tmp/ip.info The answer from ipinfo.io.
/etc/country The country saved on the first automatic detection.
/var/lib/sqlite/country.db The country whitelist.
/var/log/go/timezone.log The command log.
curl, sqlite3, timedatectl Detection, the country database, and the system timezone.
Root access Editing the php.ini files.

See also

Command Description
dst Provide timezone definitions, DST rules, and historical changes
fpm Restart all installed PHP-FPM versions on your server
maxexecutiontime Change the max execution time for all PHP versions
memorylimit Change the PHP memory limit for all PHP versions
errorreporting Read or set PHP error_reporting across all php.ini files
displayerrors Toggle PHP display_errors across all php.ini files