๐Ÿ”ฅ Weekly thread #09 of 2022

๐Ÿ”ฅ This week's code tips for Laravel developers

A weekly thread ๐Ÿงต

Use Carbon's setTimezone() and shiftTimezone() methods

2

๐Ÿ”ฅ Use Carbon's setTimezone() and shiftTimezone() methods

Use Carbon's setTimezone() and shiftTimezone() methods

Over the past few years, I've worked on some large apps that deal with events in different timezones. This can end up being quite confusing, as best practice is always to store dates in UTC.

That's where Carbon's shiftTimezone() and setTimezone() methods can help you out! โฌ‡๏ธ

Be careful about setting timezones with Carbon

1

๐Ÿ”ฅ Be careful about setting timezones with Carbon

Be careful about setting timezones with Carbon

โ—๏ธโฐ When working with Carbon/timezones, you should be aware that setting the timezone during construction is not the same as altering the timezone later. ๐Ÿ‘

We're writing a book, you can get it for free here.