Convert DateTime to different timezone

Convert DateTime to different timezone

When starting a new project, usually you don't directly start a worldwide service. Because of this most of the time you don't directly start with DateTime conversions as it's just more effort without any benefit. Luckily there are ways to add those features afterwards and also convert all DateTime entries directly within MySQL.

If you for example want to convert a created column from Europe/Berlin to UTC, you can run the following SQL command:

UPDATE user SET created = CONVERT_TZ(created, 'Europe/Berlin', 'UTC');

Depending on your MySQL setup, the timezones used by CONVERT_TZ aren't available in your instance. If that's the case, you have to import the timezone information first.