Daniel Bahl

Google Cloud SQL with daylight savings time

In Denmark we practice summer- and winter time, also called daylight savings time. Twice a year we set the clock one hour forward or one hour back. When we set the clock one hour forward, whereby we lose one hour, it is due to the change from winter to summer time.

When we set the clock one hour back, we win an extra hour, which is due to the change from daylight saving time to winter time.

When is summer time?

Summer time starts on the last Sunday in March, when the watch jumps one hour forward at 2pm at night. The summer time ends again on the last Sunday of October at the same time when the clock is set one hour back.

Here you get an overview of when you should set the clock for the next 5 years.

• 2019 – The night between Saturday 30 March and Sunday 31 March
• 2020 – The night between Saturday 28 March and Sunday 29 March
• 2021 – The night between Saturday, March 27 and Sunday, March 28th
• 2022 – The night between Saturday, March 26 and Sunday, March 27th
• 2023 – The night between Saturday 25 March and Sunday 26 March

The problem is that Googles Cloud SQL for MySQL does not support automatic adjustment to daylight savings time , from the Google Documentation of Known bugs:

Automatic adjustment to daylight savings time is not supported; you must update the default_time_zone flag manually to account for daylight savings time.

Source: cloud.google.com

In this blog-post I will cover how we can manually change this setting.

Change the database flags

Summer time:
Change the flag to:default_time_zone: +02:00

Winter time:
Change the flag to: default_time_zone: +01:00

Open the Cloud SQL Instance in the cloud.google.com console and press “Edit”:

Udfold the “Add database flags”-section and the the value to accommodate the correct time:

Test your flags

Run this Query: SELECT CURRENT_TIME()

Mac-app Querious showing the result of the query.

Daniel Bahl

Creative nerd and developer from Denmark who loves to craft beautiful apps for servers, web and mobile. Fluent in PHP, Python and Swift. Linux-user since 1998, macOS-user since 2001. Co-owner and co-founder of Cloudportal.dk, v5.dk, Cloudnet.dk, WebReview.dk, ShareShortcuts.com, Appghost.com and several other awesome websites. You'll find links and more information about everything on this website including some snippets and notes from my worklife :)

Add comment

Who is Daniel Bahl?

🐦 Follow me on Twitter

Related blogposts

Follow me on Twitter