Time Zones

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

MariaDB tiene traccia di diverse impostazioni riguardanti il fuso orario:

Time Zone di sistema

La time zone di sistema viene determinata all'avvio del server. Di solito viene letta dalla macchina host, e poi utilizzata per impostare la variabile system_time_zone. E' anche possibile impostarla con l'opzione --timezone=timezone di mysqld_safe, o impostando la variabile di ambiente TZ prima di avviare il server.

Time Zone del server

La server time zone per default è la time zone di sistema del server, e imposta la variabile time_zone. E' anche possibile impostarla con l'opzione --default-time-zone=timezone all'avvio, o modificarla a runtime se si ha il privilegio SUPER:

SET GLOBAL time_zone = timezone;

Time Zone della connessione

Anche ogni client che si connette ha una sua time zone. Questa inizialmente viene dal valore globale della variabile time_zone, che imposta il valore di sessione della stessa variabile.

Il client può però modificarla:

SET time_zone = timezone;

Gli effetti della time zone

Alcune funzioni sono influenzate dall'impostazione della time zone. Tra queste troviamo:

così come i valori registrati e recuperati dalle colonne TIMESTAMP. Questi ultimi sono convertiti in UTC (Coordinated Universal Time) al momento della scrittura, e riconvertiti al momento dell'estrazione.

Altre funzioni non sono influenzate dalla time zone. Ad esempio:

così come le colonna DATETIME, DATE e TIME.

Setting the time zone

The current time zone can be viewed by looking at the global or session contents of the time_zone system variable.

SHOW GLOBAL VARIABLES LIKE 'time_zone';
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| time_zone     | SYSTEM |
+---------------+--------+

The time zone can be specified in one of the following formats:

  • SYSTEM, the default, indicating that system time zone is being used.
  • An offset from UTC, such as +5:00 or -9:00.
  • If the mysql database time zone tables are being used, a named time zone, such as Africa/Johannesburg or Europe/Helsinki, is permissible.

mysql time zone tables

By default, the mysql time zone tables are created, but not populated. It is usually preferable for the system to handle the time zone, but you can populate the mysql time zone tables using the mysql_tzinfo_to_sql utility, which uses the zoneinfo data available on Linux, Mac OS X, FreeBSD and Solaris. Windows users will need to manually import a time zone (available at http://dev.mysql.com/downloads/timezones.html).

Time zone data updates on occasion, and the time zone tables may need to be reloaded.

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.