I think you have a simple name mismatch. The method parameter is labelled $datetime
, but in the middle line you use $value
.
Can you give an example of what you are seeing? What is stored in the datetime, what is the user's timezone, and what does this method show?
hi again,
This is the original value of the created_at column: 2016-04-20 03:12:47. Also when I saved that item the timezone of the user was on UTC.
Now upon changing the timezone it is now: Africa/Accra. And the result when I applied the function above
Array
(
[created_at] => Carbon\Carbon Object
(
[date] => 2016-04-20 03:12:47.000000
[timezone_type] => 3
[timezone] => Africa/Accra
)
)
As you can see whether which timezone I use the date is still the same. Or am I missing something here. :(.
just an update. It is now working. My problem was is I was setting a global timezone in my app which causes the irregularities.
date_default_timezone_set($userTimezone);
\Config::set('app.timezone', $userTimezone);
thank you again tdhsmith. :D
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community