'How to migrate existing MariaDB timestamp columns from local Timezone to UTC
Currently my laravel config time zone is set to '+6:00' and MariaDB database time zone is set to SYSTEM, which is +6:00 as well. Now that I need to accommodate users from different time zones, I need to migrate all timestamp values to UTC to avoid any unintended time-related issues.
In MariaDB documentation it is stated that: https://mariadb.com/kb/en/timestamp/#time-zones
If a column uses the TIMESTAMP data type, then any inserted values are converted from the session's time zone to Coordinated Universal Time (UTC) when stored, and converted back to the session's time zone when retrieved.
Now, this is where I am getting confused. What I understand from the above statement that I do not require to change anything in the database as timestamps are always stored in UTC no matter what is my session time zone is at the time of saving the data. Therefore, later on if I update my time zone to UTC in Laravel config, I should get the corresponding UTC value. But after changing the Time zone to UTC in Laravel config I am still getting the time in +6:00 format from eloquent model. I think I am missing something here and would really appreciate any suggestion regarding this. Thanks in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
