Comparing Dates
Test dates with isToday(), isPast(), isWeekend() and comparisons.
Syntax
$carbon->isWeekend();Carbon has readable boolean checks for common questions:
isPast()/isFuture()isToday()/isYesterday()isWeekend()/isWeekday()greaterThan(),lessThan(),equalTo()
Example
Loading editor…
Press Run to execute the code.
When to use it
- A feature-flag system checks isWeekend() to disable marketing pop-ups on Saturdays and Sundays when support staff are unavailable.
- A booking platform calls isPast() on an appointment's scheduled time to mark it as completed automatically in the nightly cleanup job.
- A payroll service uses isLastDayOfMonth() to determine when to trigger the monthly payroll run.
More examples
Past, future, and today checks
isPast(), isFuture(), and isToday() provide quick boolean checks on a Carbon date relative to the current moment.
use Carbon\Carbon;
$date = Carbon::parse('2024-01-01');
$date->isPast(); // true
$date->isFuture(); // false
$date->isToday(); // false
now()->isToday(); // trueDay-of-week and period checks
Carbon includes named helpers for every day of the week, plus isWeekday(), isWeekend(), and isLastDayOfMonth() for common period checks.
use Carbon\Carbon;
$dt = Carbon::parse('2025-03-14'); // a Friday
$dt->isWeekday(); // true
$dt->isWeekend(); // false
$dt->isFriday(); // true
$dt->isMonday(); // false
$dt->isLastDayOfMonth(); // false (March 14 is not March 31)Compare two dates
isBefore(), isAfter(), isSameDay(), equalTo(), and between() allow precise comparisons between two Carbon instances.
use Carbon\Carbon;
$a = Carbon::parse('2025-06-01');
$b = Carbon::parse('2025-09-01');
$a->isBefore($b); // true
$a->isAfter($b); // false
$a->isSameDay($b); // false
$a->equalTo(Carbon::parse('2025-06-01')); // true
$a->between(now(), $b); // depends on current date
Discussion