Converting the MySQL time zone

Find out how to convert the time zone in MySQL by using the CONVERT_TZ function with this guide including instructions, code snippets and links to related articles.

This article describes how to convert the time zone in MySQL by using the CONVERT_TZ function.

Using the CONVERT_TZ function

By default, hosting.com servers use one of the following time zones:

  • US-based (Michigan) servers: US Eastern Time zone.

  • Europe-based (Amsterdam) servers: Central European Time zone.

  • Asia-based (Singapore) servers: Singapore Standard Time zone.

On shared servers, you cannot change the default MySQL time zone, because this would affect other accounts on the server. However, you can convert the time zone used in DATE,TIME, and DATETIME fields by calling the CONVERT_TZ function as needed.

For example, the following sample query shows how to convert the current date and time in the US Eastern time zone to the time zone for Paris, France:

SELECT CONVERT_TZ( NOW(),'US/Eastern','Europe/Paris' );

👍

Tip

For a complete list of time zones, please visit https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.

More Information

Related Articles