beardcoder - I Have a Problem with the datetime...
# ❓questions
b
I Have a Problem with the datetime picker 😦
I can not set the correct date time zone in the frontend. the backend handles the timezone correct
Currently the only way is this code
$item->number_assignment_date->shiftTimezone('UTC')->setTimezone('Europe/Berlin')
without shiftTimezone('UTC') nothing will happend
i
hi @beardcoder did you change the default Laravel timezone (UTC)?
asking because as a good practice you probably shouldn't so that you store timezone agnostic dates in database, which is what Twill is doing
so even if you changed your default timezone, Twill still stores dates using UTC (and renders in the user timezone in the CMS)
so it makes sense that you have to indicate to carbon that the date you're trying to render is not on UTC
b
Yes I have changed the timezone to Europe/Berlin. And the behavior from Twill looks correct to store the dates in UTC. But I don’t find any solution to say carbon the timezone from the database.
Have you any solution to set the timezone from the database or transform this with a cast?
i
the problem is that a cast will affect twill too. the recommendation is to keep utc as your Laravel timezone so that it doesn't think dates in your database are stored using a different timezone (which is why you have to shift it right now). The fact that you want to show a date in a specific timezone is a concern of your application and should be dealt with at render time, not in the database.