Planet MySQL Planet MySQL: Meta Deutsch Español Français Italiano 日本語 Русский Português 中文
Showing entries 1 to 5

Displaying posts with tag: timezone (reset)

Converting Timezone-Specific Times in MySQL
+0 Vote Up -0Vote Down

Twice last week, a developer wanted to convert the existing datetime values in a database to UTC. The datetime values were the default for the server, which was the US/Pacific time zone, which is subject to Daylight Saving Time changes. Both developers for both applications wanted to convert all the times to UTC, so there would not be any changes due to Daylight Saving Time, and asked me for an easy query to know which times should be changed by adding 7 hours and which times should have 8 hours added to them.

The good news is that MySQL has some built-in functionality to make this easier. You may know about the CONVERT_TZ() function in MySQL, and that you can use it in a query to convert times like this:

mysql> SELECT

  [Read more...]
MySQL Timezone support: Updating and Monitoring
+3 Vote Up -0Vote Down
How old is your timezone info?
As the timezone database gets updated frequently, it's important to update the internal timezone database in MySQL. This is needed for the CONVERT_TZ() function for work properly.

It's not easy to determine if the data in mysql is older than the data from the tzdata database. It get's a bit better if you use this hack before importing the zone database:
ALTER TABLE mysql.time_zone_transition ADD COLUMN `Last_Update` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
I've created Bug #60675 to get the system database updated.

Which database serves still need timezone





  [Read more...]
Pear::Date Returned Timezone is Wrong
+0 Vote Up -0Vote Down

Background Knowledge


I’m trying to determine the difference in minutes between two timestamps. I’m using Pear::Date to do this. The issue comes into play when I noticed that the wrong timezone was being used by Pear::Date, UTC. If I do not use Pear::Date the timezone is set correctly.

I have tried using date_default_timezone_set() and it does set the timezone back, however I feel this shouldn’t be necessary as the default timezone should be used. I have been using date_default_timezone_get() to determine what timezone is being used.

It’s my understanding that Pear::Date uses UTC when it is unable to determine the default timezone. As far as I know I

  [Read more...]
This should *never* happen!
+0 Vote Up -0Vote Down

While playing around with the great MySQL Activity Reporter , I ran into the following error.

[client 192.168.254.72] PHP Fatal error: strftime() [function.strftime]: Timezone database is corrupt - this should *never* happen! in /var/lib/mysqlard/mysqlar.php on line 62

Now the error is clear .. the Timezone database is corrupt and I`m the one to blame for .. this was on a pretty stripped down Centos that lives in UTC. So there wasn't a real Timezone database.

Obviously a quick apt-get install tzdata solved the problem, but once again the lesson is.. don't strip too much .. you'll eventually endup needing those 3 Kb of free space you gained anyhow.

This should *never* happen!
+0 Vote Up -0Vote Down

While playing around with the great MySQL Activity Reporter , I ran into the following error.

[client 192.168.254.72] PHP Fatal error: strftime() [function.strftime]: Timezone database is corrupt - this should *never* happen! in /var/lib/mysqlard/mysqlar.php on line 62

Now the error is clear .. the Timezone database is corrupt and I`m the one to blame for .. this was on a pretty stripped down Centos that lives in UTC. So there wasn't a real Timezone database.

Obviously a quick apt-get install tzdata solved the problem, but once again the lesson is.. don't strip too much .. you'll eventually endup needing those 3 Kb of free space you gained anyhow.

Showing entries 1 to 5

Planet MySQL © 1995, 2014, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.