Let's say I have 2 TIMESTAMP fields/columns, event and stamp. For event field, when we insert, I want to set time zone so that event will use user specified time zone. However, I don't want stamp to use that time zone. I want stamp to use whatever default time zone the server is using.
SET time_zone = <UTC offset>;
does not work since it will affect both event and stamp where we only want event to be affected by the time zone.
Is there a way to set time zone for specific columns during insert?
MySQL doesn't bother about timezones when you insert a date.
I would recommend storing the date/time in GMT (+00:00) and have another field that stores the timezone used (e.g. "Europe/Amsterdam").
Edit
I'm not entirely sure you would need the used timezone though, since you can format a GMT time in any way you'd like inside your scripts / apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With