What does this give you?
dd($messages->first()->created_at->setTimezone($user_timezone)->tzName);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
My goal is to get the timestamp stored in database and show it in human readable format to the user based on their 'timezone'.
This looked easy; and here's why I have -
$messages->first()->created_at->setTimezone($user_timezone)->format('d M y, h:m a')
So if the message was received at 5:00PM in India, it should be some other time shown to the user viewing it from Europe or USA. However, this is not working as expected. I'm getting the same date for every user; irrespective of the timezone.
The date set in database is UTC. What am I doing wrong?
Please or to participate in this conversation.