No Need to Convert Carbon

If you're performing whereDate() and check today's records, you can use Carbon's now() and it will automatically be transformed to date. No need to do ->toDateString().

1// Instead of
2$todayUsers = User::whereDate('created_at', now()->toDateString())->get();
3// No need to convert, just use now()
4$todayUsers = User::whereDate('created_at', now())->get();

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord