WordPress and daylight saving

WordPress has a wonderful feature: instead of providing a timezone where you live, you tell it how much hours your local time differs from GMT. Which just fails when dealing with daylight saving.

And I just noticed that my setting was still 1 hour, instead of 2. I remembered to change time on my wallclocks, mobile phone, but I forgot my blog... But changing that will change it only for future posts and comments.

So, for people who forgot like me, here are two SQL queries to fix the database:

update wp_posts set post_date = convert_tz(post_date_gmt, 'GMT', 'Europe/Paris'), post_modified = convert_tz(post_modified_gmt, 'GMT', 'Europe/Paris');
update wp_comments set comment_date = convert_tz(comment_date_gmt, 'GMT', 'Europe/Paris');

Don't forget to replace Europe/Paris with whatever your timezone is ;) . Note that this will require you to run, if you've never done it before, something like
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -p -u root mysql

2006-06-25 22:39:02+0900

p.d.o, website

Both comments and pings are currently closed.

2 Responses to “WordPress and daylight saving”

  1. Carlos Says:

    Hey Mike,

    there’s a wordpress plugin to deal with this:

    http://kimmo.suominen.com/sw/timezone/

    Cheers

  2. glandium Says:

    I actually found this one this morning. Thanks anyway.

    Note the SQL queries are still useful for older posts.