使用Laravel的MySQL时区

I want to store a Carbon date time object in a MySQL Database and I am using Laravel Eloquent to do this.

I have build a test with different data types (dateTime, dateTimeTz, timestamp and timestampTz from Laravel Migrations) and every one cuts off the time zone and only stores the date and time. When the data is accessed again Laravel assumes the default time zone from config and I have invalid data.

Is there a way to either preserve the time zone or to automatically convert the date and time to UTC or the config time zone?

MySQL doesn't provide any features to store Timestamp with Timezone. You have to separately maintain all the timezone manually.

You can define seprate column for maintaining the timezone when the Timestamp retrieved from the Database you can convert Timestamp to related Timezone.

For that you can use Laravel features Accessors.