Aller au contenu

Converting the MySQL time zone

Ce contenu n’est pas encore disponible dans votre langue.

Ruachost servers, including MySQL, run on UTC (GMT+0).

On shared servers, you cannot change the default MySQL time zone, because it affects other accounts on the server. However, you can convert the time zone for DATE, TIME, and DATETIME fields by using the CONVERT_TZ function.

Example: Convert the current server time (UTC) to Lagos, Nigeria:

SELECT CONVERT_TZ(NOW(), '+00:00', '+01:00');

Using UTC offsets such as +01:00 always works. Named zones such as Africa/Lagos only work if the server has the MySQL time zone tables loaded.

Cette page vous a-t-elle aidé ?