laravel-timezones icon indicating copy to clipboard operation
laravel-timezones copied to clipboard

different set and get timezone support

Open opheus2 opened this issue 1 year ago • 3 comments
trafficstars

For global consistency, I believe it makes sense to support having the dates stored in one timezone and can be shown in any other timezone using the cast. While this is achievable via the ::set method on different cases and middleware, I think it would be more convenient to do it via the cast.

NB: I only took a glance at the codes, so I'm not 100% sure if this isn't already doable via the cast.

Ofc it can still be done by create a new cast that extends yours, but I think it would be better to have this within the package.

If you think this is feasible, I'm open to creating a PR

opheus2 avatar Apr 27 '24 18:04 opheus2

To be honest, I'm not entirely sure I understand what you're asking. Could you provide an example? Thanks!

toonvandenbos avatar Apr 27 '24 20:04 toonvandenbos

So see it this way.

All timestamps are created with UTC, but when it's fetched, it should use the user's timezone.

Is this possible with the cast?

opheus2 avatar Apr 28 '24 16:04 opheus2

Yup, that's exactly what this package was built for 🙂

What doesn't work for you? Did you try to implement the example from the README?

toonvandenbos avatar Apr 29 '24 07:04 toonvandenbos