Home >Database >Mysql Tutorial >How Can I Correct Timezone Discrepancies Between UTC and GMT 1 in MySQL?

How Can I Correct Timezone Discrepancies Between UTC and GMT 1 in MySQL?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-03 15:31:12773browse

How Can I Correct Timezone Discrepancies Between UTC and GMT 1 in MySQL?

Correcting Timezone Discrepancy: Transitioning UTC to GMT 1

Encountering a timezone discrepancy between UTC and GMT 1 can be resolved with ease using MySQL commands. Here's the solution:

Setting the Global Timezone

To adjust the global timezone, you can use the following command in phpMyAdmin's SQL execution section:

SET GLOBAL time_zone = 'Europe/London';

Ensure to replace 'Europe/London' with the desired GMT 1 timezone value.

Handling Daylights Savings Adjustments

The named timezone is crucial for timezones that undergo daylights savings adjustments. Consider the command:

SET GLOBAL time_zone = 'America/New_York';

This sets the global timezone to America's Eastern Time Zone, which factors in daylights savings.

Resolving "Unknown or Incorrect Time Zone" Error

For certain Linux builds, you may encounter the error "#1298 - Unknown or incorrect time zone." To address this:

  1. From the Linux command line, execute:
mysql_tzinfo_to_sql /usr/share/zoneinfo/|mysql -u root mysql -p
  1. Provide the root password for MySQL and run the command.

This will import all definitions from your zoneinfo into MySQL.

  1. Re-run the SET GLOBAL time_zone command to establish the desired timezone.

The above is the detailed content of How Can I Correct Timezone Discrepancies Between UTC and GMT 1 in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn