Level 2
If you want to chage timezone for the whole app you have to change it in config.app file
'timezone' => 'Asia/Colombo'
This will also change created_at, updated_at time to the mentioned timezone
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can i convert following time into Sri Lanka time.
"recording_start" => "2021-02-26T03:49:20Z"
"recording_end" => "2021-02-26T03:49:26Z"
I tried. this one not works
$recordingStart = \Carbon\Carbon::parse($recordingStart)->toDateTimeString();
$recordingStart = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $recordingStart, 'Asia/Colombo');
dd($recordingStart);
Use setTimezone on the Carbon instance, e.g.
\Carbon\Carbon::parse("2021-02-26T03:49:20Z")->setTimezone('Asia/Colombo')->toDateTimeString();
// => "2021-02-26 09:19:20"
Please or to participate in this conversation.