I have model with several timestamp columns – created_at, updated_at and published_at.
In migration I have:
$table->timestamp('published_at')->nullable();
$table->timestamps();
On the model I have:
protected $casts = [
'created_at' => 'datetime:j F Y, H:i T',
'published_at' => 'datetime:j F Y, H:i T',
'updated_at' => 'datetime:j F Y, H:i T',
];
… but on the result I have two different timezones, “Z” ( for created_at and updated_at ) and “UTC” ( for published_at ). Technically, ZULU and UTC are the same, but I want to use only one timezone on website – UTC.
When I removed formatting from casts:
protected $casts = [
'created_at' => 'datetime',
'published_at' => 'datetime',
'updated_at' => 'datetime',
];
… all three timestamps have the same timezone – “Z”.
I have no idea how to fix this “mishmash”
This problem does not occur on Laravel 10 – all timezones are “UTC”
Where is the problem please!?
I tried search on Carbon and Laravel documentation but I didn’t find the answer.