Laravel Pro Tips
🔥 If you've ever found yourself manually dealing with request inputs looking to parse it to Carbon. You might want to use the `date` method on the Request instance instead. #Laravel #PHP
Morten Poul Jensen
🔥 #Laravel Tip: If you need to render dates and times a lot in your app, then consider making a custom Carbon class. You can then tell Laravel to always use your class via the Date facade.
Carbon provides next() and previous() functions that return upcoming and previous occurrences of a particular weekday or time.
❗️⏰ When working with Carbon/timezones, you should be aware that setting the timezone during construction is not the same as altering the timezone later. 👍
Freek Van der Herten 🔭
🔥 Laravel tip: Use the CarbonImmutable class instead of Carbon to avoid changing the object without having to clone it.
One of the reasons I really like using Laravel. Get a Carbon instance directly from Request in Laravel. Slick little feature. Loads more features in a snapshot here https://t.co/FGGk7nx6lM
James Riordon 🇺🇦
A pull request recently got merged into Laravel that allows you to use the "->when()" method on a PendingRequest 🔥
Ash Allen 🚀
When getting PREVIOUS month, be careful with Carbon subMonth you might not get the result that you’re expecting. You may want to checkout subMonthWithNoOverflow instead
💡There's a really helpful date helper on the Request class.
You can retrieve a value as a Carbon instance:
Apr 17th, 2022
Carbon PHP Practical Examples
I've been working and experimenting a lot lately with Carbon, the sublime PHP date and time utility library. I've tweeted a lot of Carbon tips and decided to collect all these tips into a permanent article.