Skip to content
Advertisement

Laravel – convert time to user’s timezone in model

I have the following model that returns data from Dynamo AWS, my data has a time in EPOCH, and I convert it to the formatted date as below:

JavaScript

However, the time returning does not match the time that the user is seeing the data and that is why I would like to make the conversion using the registration timezone as an extra field in the user:

JavaScript

I tried to do something like this: UPDATE

JavaScript

It’s not even calling my function, when I do this:

JavaScript

But it doesn’t work, can someone help me how to make this conversion?

Advertisement

Answer

I would say read more about Accessors and Mutators

Would be something like

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement