Menu

## Comparison

Comparison.php : 44

Trait Comparison.

Comparison utils and testers. All the following methods return booleans. nowWithSameTz

Depends on the following methods:

### Table of Contents

#### Properties

$endOfTime : bool
$startOfTime : bool

#### Methods

between() : bool
  Determines if the instance is between two others.
betweenExcluded() : bool
  Determines if the instance is between two others, bounds excluded.
betweenIncluded() : bool
  Determines if the instance is between two others, bounds included.
canBeCreatedFromFormat() : bool
  Checks if the (date)time string is in a given format and valid to create a new instance.
copy() : void
eq() : bool
  Determines if the instance is equal to another
equalTo() : bool
  Determines if the instance is equal to another
greaterThan() : bool
  Determines if the instance is greater (after) than another
greaterThanOrEqualTo() : bool
  Determines if the instance is greater (after) than or equal to another
gt() : bool
  Determines if the instance is greater (after) than another
gte() : bool
  Determines if the instance is greater (after) than or equal to another
hasFormat() : bool
  Checks if the (date)time string is in a given format.
hasFormatWithModifiers() : bool
  Checks if the (date)time string is in a given format.
is() : bool
  Returns true if the current date matches the given string.
isAfter() : bool
  Determines if the instance is greater (after) than another
isBefore() : bool
  Determines if the instance is less (before) than another
isBetween() : bool
  Determines if the instance is between two others
isBirthday() : bool
  Check if its the birthday. Compares the date/month values of the two dates.
isCurrentUnit() : bool
  Determines if the instance is in the current unit given.
isDayOfWeek() : bool
  Checks if this day is a specific day of the week.
isEndOfCentury() : bool
  Determines if the instance is end of century (last day by default but interval can be customized).
isEndOfDay() : bool
  Check if the instance is end of day.
isEndOfDecade() : bool
  Determines if the instance is end of decade (last day by default but interval can be customized).
isEndOfHour() : bool
  Determines if the instance is end of hour (last microsecond by default but interval can be customized).
isEndOfMillennium() : bool
  Determines if the instance is end of millennium (last day by default but interval can be customized).
isEndOfMillisecond() : bool
  Determines if the instance is end of millisecond (last microsecond by default but interval can be customized).
isEndOfMinute() : bool
  Determines if the instance is end of minute (last microsecond by default but interval can be customized).
isEndOfMonth() : bool
  Determines if the instance is end of month (last day by default but interval can be customized).
isEndOfQuarter() : bool
  Determines if the instance is end of quarter (last day by default but interval can be customized).
isEndOfSecond() : bool
  Determines if the instance is end of second (last microsecond by default but interval can be customized).
isEndOfTime() : bool
  Returns true if the date was created using CarbonImmutable::endOfTime()
isEndOfUnit() : bool
  Check if the instance is end of a given unit (tolerating a given interval).
isEndOfWeek() : bool
  Determines if the instance is end of week (last day by default but interval can be customized).
isEndOfYear() : bool
  Determines if the instance is end of year (last day by default but interval can be customized).
isFuture() : bool
  Determines if the instance is in the future, ie. greater (after) than now.
isLastOfMonth() : bool
  Check if today is the last day of the Month
isLeapYear() : bool
  Determines if the instance is a leap year.
isLongIsoYear() : bool
  Determines if the instance is a long year (using ISO 8601 year).
isLongYear() : bool
  Determines if the instance is a long year (using calendar year).
isMidday() : bool
  Check if the instance is midday.
isMidnight() : bool
  Check if the instance is start of day / midnight.
isPast() : bool
  Determines if the instance is in the past, ie. less (before) than now.
isSameAs() : bool
  Compares the formatted values of the two dates.
isSameMonth() : bool
  Checks if the passed in date is in the same month as the instance´s month.
isSameQuarter() : bool
  Checks if the passed in date is in the same quarter as the instance quarter (and year if needed).
isSameUnit() : bool
  Determines if the instance is in the current unit given.
isStartOfCentury() : bool
  Determines if the instance is start of century (first day by default but interval can be customized).
isStartOfDay() : bool
  Check if the instance is start of day / midnight.
isStartOfDecade() : bool
  Determines if the instance is start of decade (first day by default but interval can be customized).
isStartOfHour() : bool
  Determines if the instance is start of hour (first microsecond by default but interval can be customized).
isStartOfMillennium() : bool
  Determines if the instance is start of millennium (first day by default but interval can be customized).
isStartOfMillisecond() : bool
  Determines if the instance is start of millisecond (first microsecond by default but interval can be customized).
isStartOfMinute() : bool
  Determines if the instance is start of minute (first microsecond by default but interval can be customized).
isStartOfMonth() : bool
  Determines if the instance is start of month (first day by default but interval can be customized).
isStartOfQuarter() : bool
  Determines if the instance is start of quarter (first day by default but interval can be customized).
isStartOfSecond() : bool
  Determines if the instance is start of second (first microsecond by default but interval can be customized).
isStartOfTime() : bool
  Returns true if the date was created using CarbonImmutable::startOfTime()
isStartOfUnit() : bool
  Check if the instance is start of a given unit (tolerating a given interval).
isStartOfWeek() : bool
  Determines if the instance is start of week (first day by default but interval can be customized).
isStartOfYear() : bool
  Determines if the instance is start of year (first day by default but interval can be customized).
isToday() : bool
  Determines if the instance is today.
isTomorrow() : bool
  Determines if the instance is tomorrow.
isWeekday() : bool
  Determines if the instance is a weekday.
isWeekend() : bool
  Determines if the instance is a weekend day.
isYesterday() : bool
  Determines if the instance is yesterday.
lessThan() : bool
  Determines if the instance is less (before) than another
lessThanOrEqualTo() : bool
  Determines if the instance is less (before) or equal to another
lt() : bool
  Determines if the instance is less (before) than another
lte() : bool
  Determines if the instance is less (before) or equal to another
ne() : bool
  Determines if the instance is not equal to another
notEqualTo() : bool
  Determines if the instance is not equal to another
nowWithSameTz() : void
resolveCarbon() : void
tomorrow() : static
yesterday() : static

### Properties

#### $endOfTime

Comparison.php : 46
`protected bool $endOfTime = false`

#### $startOfTime

Comparison.php : 48
`protected bool $startOfTime = false`

### Methods

#### between()

Comparison.php : 293

Determines if the instance is between two others.

`public between(DateTimeInterface|string $date1, DateTimeInterface|string $date2[, bool $equal = true ]) : bool`

The third argument allow you to specify if bounds are included or not (true by default) but for when you including/excluding bounds may produce different results in your application, we recommend to use the explicit methods ->betweenIncluded() or ->betweenExcluded() instead.

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string
$equal : bool = true

  Indicates if an equal to comparison should be done

##### Tags

example

      Carbon::parse('2018-07-25')->between('2018-07-14', '2018-08-01'); // true
      Carbon::parse('2018-07-25')->between('2018-08-01', '2018-08-20'); // false
      Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01'); // true
      Carbon::parse('2018-07-25')->between('2018-07-25', '2018-08-01', false); // false

##### Return values

bool

#### betweenExcluded()

Comparison.php : 334

Determines if the instance is between two others, bounds excluded.

`public betweenExcluded(DateTimeInterface|string $date1, DateTimeInterface|string $date2) : bool`

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25')->betweenExcluded('2018-07-14', '2018-08-01'); // true
      Carbon::parse('2018-07-25')->betweenExcluded('2018-08-01', '2018-08-20'); // false
      Carbon::parse('2018-07-25')->betweenExcluded('2018-07-25', '2018-08-01'); // false

##### Return values

bool

#### betweenIncluded()

Comparison.php : 319

Determines if the instance is between two others, bounds included.

`public betweenIncluded(DateTimeInterface|string $date1, DateTimeInterface|string $date2) : bool`

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25')->betweenIncluded('2018-07-14', '2018-08-01'); // true
      Carbon::parse('2018-07-25')->betweenIncluded('2018-08-01', '2018-08-20'); // false
      Carbon::parse('2018-07-25')->betweenIncluded('2018-07-25', '2018-08-01'); // true

##### Return values

bool

#### canBeCreatedFromFormat()

Comparison.php : 1190

Checks if the (date)time string is in a given format and valid to create a new instance.

`public static canBeCreatedFromFormat(string|null $date, string $format) : bool`

##### Parameters

$date : string|null
$format : string

##### Tags

example

      Carbon::canBeCreatedFromFormat('11:12:45', 'h:i:s'); // true
      Carbon::canBeCreatedFromFormat('13:12:45', 'h:i:s'); // false

##### Return values

bool

#### copy()

Comparison.php : 0
`public static copy() : void`

#### eq()

Comparison.php : 62

Determines if the instance is equal to another

`public eq(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:16'); // true
      Carbon::parse('2018-07-25 12:45:16')->eq(Carbon::parse('2018-07-25 12:45:16')); // true
      Carbon::parse('2018-07-25 12:45:16')->eq('2018-07-25 12:45:17'); // false

see
  equalTo()

##### Return values

bool

#### equalTo()

Comparison.php : 77

Determines if the instance is equal to another

`public equalTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:16'); // true
      Carbon::parse('2018-07-25 12:45:16')->equalTo(Carbon::parse('2018-07-25 12:45:16')); // true
      Carbon::parse('2018-07-25 12:45:16')->equalTo('2018-07-25 12:45:17'); // false

##### Return values

bool

#### greaterThan()

Comparison.php : 141

Determines if the instance is greater (after) than another

`public greaterThan(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:15'); // true
      Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->greaterThan('2018-07-25 12:45:17'); // false

##### Return values

bool

#### greaterThanOrEqualTo()

Comparison.php : 190

Determines if the instance is greater (after) than or equal to another

`public greaterThanOrEqualTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:15'); // true
      Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:16'); // true
      Carbon::parse('2018-07-25 12:45:16')->greaterThanOrEqualTo('2018-07-25 12:45:17'); // false

##### Return values

bool

#### gt()

Comparison.php : 126

Determines if the instance is greater (after) than another

`public gt(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:15'); // true
      Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->gt('2018-07-25 12:45:17'); // false

see
  greaterThan()

##### Return values

bool

#### gte()

Comparison.php : 175

Determines if the instance is greater (after) than or equal to another

`public gte(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:15'); // true
      Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:16'); // true
      Carbon::parse('2018-07-25 12:45:16')->gte('2018-07-25 12:45:17'); // false

see
  greaterThanOrEqualTo()

##### Return values

bool

#### hasFormat()

Comparison.php : 1156

Checks if the (date)time string is in a given format.

`public static hasFormat(string $date, string $format) : bool`

##### Parameters

$date : string
$format : string

##### Tags

example

      Carbon::hasFormat('11:12:45', 'h:i:s'); // true
      Carbon::hasFormat('13:12:45', 'h:i:s'); // false

##### Return values

bool

#### hasFormatWithModifiers()

Comparison.php : 1175

Checks if the (date)time string is in a given format.

`public static hasFormatWithModifiers(string $date, string $format) : bool`

##### Parameters

$date : string
$format : string

##### Tags

example

      Carbon::hasFormatWithModifiers('31/08/2015', 'd#m#Y'); // true
      Carbon::hasFormatWithModifiers('31/08/2015', 'm#d#Y'); // false

##### Return values

bool

#### is()

Comparison.php : 1231

Returns true if the current date matches the given string.

`public is(string $tester) : bool`

##### Parameters

$tester : string

  day name, month name, hour, date, etc. as string

##### Tags

example

      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2018')); // false
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('06-02')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('2019-06-02')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('Sunday')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('June')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:45')); // true
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12:23:00')); // false
      var_dump(Carbon::parse('2019-06-02 12:23:45')->is('12h')); // true
      var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3pm')); // true
      var_dump(Carbon::parse('2019-06-02 15:23:45')->is('3am')); // false

##### Return values

bool

#### isAfter()

Comparison.php : 158

Determines if the instance is greater (after) than another

`public isAfter(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:15'); // true
      Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->isAfter('2018-07-25 12:45:17'); // false

see
  greaterThan()

##### Return values

bool

#### isBefore()

Comparison.php : 239

Determines if the instance is less (before) than another

`public isBefore(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:15'); // false
      Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->isBefore('2018-07-25 12:45:17'); // true

see
  lessThan()

##### Return values

bool

#### isBetween()

Comparison.php : 352

Determines if the instance is between two others

`public isBetween(DateTimeInterface|string $date1, DateTimeInterface|string $date2[, bool $equal = true ]) : bool`

##### Parameters

$date1 : DateTimeInterface|string
$date2 : DateTimeInterface|string
$equal : bool = true

  Indicates if an equal to comparison should be done

##### Tags

example

      Carbon::parse('2018-07-25')->isBetween('2018-07-14', '2018-08-01'); // true
      Carbon::parse('2018-07-25')->isBetween('2018-08-01', '2018-08-20'); // false
      Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01'); // true
      Carbon::parse('2018-07-25')->isBetween('2018-07-25', '2018-08-01', false); // false

##### Return values

bool

#### isBirthday()

Comparison.php : 699

Check if its the birthday. Compares the date/month values of the two dates.

`public isBirthday([DateTimeInterface|string|null $date = null ]) : bool`

##### Parameters

$date : DateTimeInterface|string|null = null

  The instance to compare with or null to use current day.

##### Tags

example

      Carbon::now()->subYears(5)->isBirthday(); // true
      Carbon::now()->subYears(5)->subDay()->isBirthday(); // false
      Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-05')); // true
      Carbon::parse('2019-06-05')->isBirthday(Carbon::parse('2001-06-06')); // false

##### Return values

bool

#### isCurrentUnit()

Comparison.php : 611

Determines if the instance is in the current unit given.

`public isCurrentUnit(string $unit) : bool`

##### Parameters

$unit : string

  The unit to test.

##### Tags

example

      Carbon::now()->isCurrentUnit('hour'); // true
      Carbon::now()->subHours(2)->isCurrentUnit('hour'); // false

throws
  BadMethodCallException

##### Return values

bool

#### isDayOfWeek()

Comparison.php : 675

Checks if this day is a specific day of the week.

`public isDayOfWeek(int|string $dayOfWeek) : bool`

##### Parameters

$dayOfWeek : int|string

##### Tags

example

      Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::WEDNESDAY); // true
      Carbon::parse('2019-07-17')->isDayOfWeek(Carbon::FRIDAY); // false
      Carbon::parse('2019-07-17')->isDayOfWeek('Wednesday'); // true
      Carbon::parse('2019-07-17')->isDayOfWeek('Friday'); // false

##### Return values

bool

#### isEndOfCentury()

Comparison.php : 1091

Determines if the instance is end of century (last day by default but interval can be customized).

`public isEndOfCentury([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfDay()

Comparison.php : 936

Check if the instance is end of day.

`public isEndOfDay([bool $checkMicroseconds = false ][, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$checkMicroseconds : bool = false

  check time at microseconds precision

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

  if an interval is specified it will be used as precision for instance with "15 minutes", it checks if current date-time is in the last 15 minutes of the day, with Unit::Hour, it checks if it's in the last hour of the day.

##### Tags

example

      Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(); // true
      Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(); // true
      Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(); // true
      Carbon::parse('2019-02-28 23:59:58.999999')->isEndOfDay(); // false
      Carbon::parse('2019-02-28 23:59:59.999999')->isEndOfDay(true); // true
      Carbon::parse('2019-02-28 23:59:59.123456')->isEndOfDay(true); // false
      Carbon::parse('2019-02-28 23:59:59')->isEndOfDay(true); // false

##### Return values

bool

#### isEndOfDecade()

Comparison.php : 1073

Determines if the instance is end of decade (last day by default but interval can be customized).

`public isEndOfDecade([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfHour()

Comparison.php : 851

Determines if the instance is end of hour (last microsecond by default but interval can be customized).

`public isEndOfHour([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMillennium()

Comparison.php : 1109

Determines if the instance is end of millennium (last day by default but interval can be customized).

`public isEndOfMillennium([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMillisecond()

Comparison.php : 797

Determines if the instance is end of millisecond (last microsecond by default but interval can be customized).

`public isEndOfMillisecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMinute()

Comparison.php : 833

Determines if the instance is end of minute (last microsecond by default but interval can be customized).

`public isEndOfMinute([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfMonth()

Comparison.php : 1019

Determines if the instance is end of month (last day by default but interval can be customized).

`public isEndOfMonth([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfQuarter()

Comparison.php : 1037

Determines if the instance is end of quarter (last day by default but interval can be customized).

`public isEndOfQuarter([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfSecond()

Comparison.php : 815

Determines if the instance is end of second (last microsecond by default but interval can be customized).

`public isEndOfSecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isEndOfTime()

Comparison.php : 1329

Returns true if the date was created using CarbonImmutable::endOfTime()

`public isEndOfTime() : bool`

##### Return values

bool

#### isEndOfUnit()

Comparison.php : 762

Check if the instance is end of a given unit (tolerating a given interval).

`public isEndOfUnit(Unit $unit[, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ], mixed ...$params) : bool`

##### Parameters

$unit : Unit
$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$params : mixed

##### Tags

example

      // Check if a date-time is the last 15 minutes of the hour it's in
      Carbon::parse('2019-02-28 20:13:00')->isEndOfUnit(Unit::Hour, '15 minutes'); // false

##### Return values

bool

#### isEndOfWeek()

Comparison.php : 1000

Determines if the instance is end of week (last day by default but interval can be customized).

`public isEndOfWeek([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ][, WeekDay|int|null $weekEndsAt = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$weekEndsAt : WeekDay|int|null = null

##### Tags

example

      Carbon::parse('2024-08-31')->endOfWeek()->isEndOfWeek(); // true
      Carbon::parse('2024-08-31')->isEndOfWeek(); // false

##### Return values

bool

#### isEndOfYear()

Comparison.php : 1055

Determines if the instance is end of year (last day by default but interval can be customized).

`public isEndOfYear([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isFuture()

Comparison.php : 444

Determines if the instance is in the future, ie. greater (after) than now.

`public isFuture() : bool`

##### Tags

example

      Carbon::now()->addHours(5)->isFuture(); // true
      Carbon::now()->subHours(5)->isFuture(); // false

##### Return values

bool

#### isLastOfMonth()

Comparison.php : 716

Check if today is the last day of the Month

`public isLastOfMonth() : bool`

##### Tags

example

      Carbon::parse('2019-02-28')->isLastOfMonth(); // true
      Carbon::parse('2019-03-28')->isLastOfMonth(); // false
      Carbon::parse('2019-03-30')->isLastOfMonth(); // false
      Carbon::parse('2019-03-31')->isLastOfMonth(); // true
      Carbon::parse('2019-04-30')->isLastOfMonth(); // true

##### Return values

bool

#### isLeapYear()

Comparison.php : 472

Determines if the instance is a leap year.

`public isLeapYear() : bool`

##### Tags

example

      Carbon::parse('2020-01-01')->isLeapYear(); // true
      Carbon::parse('2019-01-01')->isLeapYear(); // false

##### Return values

bool

#### isLongIsoYear()

Comparison.php : 512

Determines if the instance is a long year (using ISO 8601 year).

`public isLongIsoYear() : bool`

##### Tags

example

      Carbon::parse('2015-01-01')->isLongIsoYear(); // true
      Carbon::parse('2016-01-01')->isLongIsoYear(); // true
      Carbon::parse('2016-01-03')->isLongIsoYear(); // false
      Carbon::parse('2019-12-29')->isLongIsoYear(); // false
      Carbon::parse('2019-12-30')->isLongIsoYear(); // true

see
  https://en.wikipedia.org/wiki/ISO_8601#Week_dates

##### Return values

bool

#### isLongYear()

Comparison.php : 493

Determines if the instance is a long year (using calendar year).

`public isLongYear() : bool`

⚠️ This method completely ignores month and day to use the numeric year number, it's not correct if the exact date matters. For instance as `2019-12-30` is already in the first week of the 2020 year, if you want to know from this date if ISO week year 2020 is a long year, use `isLongIsoYear` instead.

##### Tags

example

      Carbon::create(2015)->isLongYear(); // true
      Carbon::create(2016)->isLongYear(); // false

see
  https://en.wikipedia.org/wiki/ISO_8601#Week_dates

##### Return values

bool

#### isMidday()

Comparison.php : 1141

Check if the instance is midday.

`public isMidday() : bool`

##### Tags

example

      Carbon::parse('2019-02-28 11:59:59.999999')->isMidday(); // false
      Carbon::parse('2019-02-28 12:00:00')->isMidday(); // true
      Carbon::parse('2019-02-28 12:00:00.999999')->isMidday(); // true
      Carbon::parse('2019-02-28 12:00:01')->isMidday(); // false

##### Return values

bool

#### isMidnight()

Comparison.php : 1125

Check if the instance is start of day / midnight.

`public isMidnight() : bool`

##### Tags

example

      Carbon::parse('2019-02-28 00:00:00')->isMidnight(); // true
      Carbon::parse('2019-02-28 00:00:00.999999')->isMidnight(); // true
      Carbon::parse('2019-02-28 00:00:01')->isMidnight(); // false

##### Return values

bool

#### isPast()

Comparison.php : 458

Determines if the instance is in the past, ie. less (before) than now.

`public isPast() : bool`

##### Tags

example

      Carbon::now()->subHours(5)->isPast(); // true
      Carbon::now()->addHours(5)->isPast(); // false

##### Return values

bool

#### isSameAs()

Comparison.php : 529

Compares the formatted values of the two dates.

`public isSameAs(string $format, DateTimeInterface|string $date) : bool`

##### Parameters

$format : string

  date formats to compare.

$date : DateTimeInterface|string

  instance to compare with or null to use current day.

##### Tags

example

      Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-12-13')); // true
      Carbon::parse('2019-06-13')->isSameAs('Y-d', Carbon::parse('2019-06-14')); // false

##### Return values

bool

#### isSameMonth()

Comparison.php : 655

Checks if the passed in date is in the same month as the instance´s month.

`public isSameMonth(DateTimeInterface|string $date[, bool $ofSameYear = true ]) : bool`

##### Parameters

$date : DateTimeInterface|string

  The instance to compare with or null to use the current date.

$ofSameYear : bool = true

  Check if it is the same month in the same year.

##### Tags

example

      Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-01-01')); // true
      Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2019-02-01')); // false
      Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01')); // false
      Carbon::parse('2019-01-12')->isSameMonth(Carbon::parse('2018-01-01'), false); // true

##### Return values

bool

#### isSameQuarter()

Comparison.php : 632

Checks if the passed in date is in the same quarter as the instance quarter (and year if needed).

`public isSameQuarter(DateTimeInterface|string $date[, bool $ofSameYear = true ]) : bool`

##### Parameters

$date : DateTimeInterface|string

  The instance to compare with or null to use current day.

$ofSameYear : bool = true

  Check if it is the same month in the same year.

##### Tags

example

      Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-03-01')); // true
      Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2019-04-01')); // false
      Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01')); // false
      Carbon::parse('2019-01-12')->isSameQuarter(Carbon::parse('2018-03-01'), false); // true

##### Return values

bool

#### isSameUnit()

Comparison.php : 550

Determines if the instance is in the current unit given.

`public isSameUnit(string $unit, DateTimeInterface|string $date) : bool`

##### Parameters

$unit : string

  singular unit string

$date : DateTimeInterface|string

  instance to compare with or null to use current day.

##### Tags

example

      Carbon::parse('2019-01-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // true
      Carbon::parse('2018-12-13')->isSameUnit('year', Carbon::parse('2019-12-25')); // false

throws
  BadComparisonUnitException

##### Return values

bool

#### isStartOfCentury()

Comparison.php : 1082

Determines if the instance is start of century (first day by default but interval can be customized).

`public isStartOfCentury([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfDay()

Comparison.php : 875

Check if the instance is start of day / midnight.

`public isStartOfDay([bool $checkMicroseconds = false ][, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$checkMicroseconds : bool = false

  check time at microseconds precision

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

  if an interval is specified it will be used as precision for instance with "15 minutes", it checks if current date-time is in the last 15 minutes of the day, with Unit::Hour, it checks if it's in the last hour of the day.

##### Tags

example

      Carbon::parse('2019-02-28 00:00:00')->isStartOfDay(); // true
      Carbon::parse('2019-02-28 00:00:00.999999')->isStartOfDay(); // true
      Carbon::parse('2019-02-28 00:00:01')->isStartOfDay(); // false
      Carbon::parse('2019-02-28 00:00:00.000000')->isStartOfDay(true); // true
      Carbon::parse('2019-02-28 00:00:00.000012')->isStartOfDay(true); // false

##### Return values

bool

#### isStartOfDecade()

Comparison.php : 1064

Determines if the instance is start of decade (first day by default but interval can be customized).

`public isStartOfDecade([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfHour()

Comparison.php : 842

Determines if the instance is start of hour (first microsecond by default but interval can be customized).

`public isStartOfHour([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMillennium()

Comparison.php : 1100

Determines if the instance is start of millennium (first day by default but interval can be customized).

`public isStartOfMillennium([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMillisecond()

Comparison.php : 788

Determines if the instance is start of millisecond (first microsecond by default but interval can be customized).

`public isStartOfMillisecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMinute()

Comparison.php : 824

Determines if the instance is start of minute (first microsecond by default but interval can be customized).

`public isStartOfMinute([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfMonth()

Comparison.php : 1010

Determines if the instance is start of month (first day by default but interval can be customized).

`public isStartOfMonth([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfQuarter()

Comparison.php : 1028

Determines if the instance is start of quarter (first day by default but interval can be customized).

`public isStartOfQuarter([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfSecond()

Comparison.php : 806

Determines if the instance is start of second (first microsecond by default but interval can be customized).

`public isStartOfSecond([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isStartOfTime()

Comparison.php : 1319

Returns true if the date was created using CarbonImmutable::startOfTime()

`public isStartOfTime() : bool`

##### Return values

bool

#### isStartOfUnit()

Comparison.php : 730

Check if the instance is start of a given unit (tolerating a given interval).

`public isStartOfUnit(Unit $unit[, Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ], mixed ...$params) : bool`

##### Parameters

$unit : Unit
$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$params : mixed

##### Tags

example

      // Check if a date-time is the first 15 minutes of the hour it's in
      Carbon::parse('2019-02-28 20:13:00')->isStartOfUnit(Unit::Hour, '15 minutes'); // true

##### Return values

bool

#### isStartOfWeek()

Comparison.php : 984

Determines if the instance is start of week (first day by default but interval can be customized).

`public isStartOfWeek([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ][, WeekDay|int|null $weekStartsAt = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null
$weekStartsAt : WeekDay|int|null = null

##### Tags

example

      Carbon::parse('2024-08-31')->startOfWeek()->isStartOfWeek(); // true
      Carbon::parse('2024-08-31')->isStartOfWeek(); // false

##### Return values

bool

#### isStartOfYear()

Comparison.php : 1046

Determines if the instance is start of year (first day by default but interval can be customized).

`public isStartOfYear([Unit|DateInterval|Closure|CarbonConverterInterface|string|null $interval = null ]) : bool`

##### Parameters

$interval : Unit|DateInterval|Closure|CarbonConverterInterface|string|null = null

##### Return values

bool

#### isToday()

Comparison.php : 414

Determines if the instance is today.

`public isToday() : bool`

##### Tags

example

      Carbon::today()->isToday(); // true
      Carbon::tomorrow()->isToday(); // false

##### Return values

bool

#### isTomorrow()

Comparison.php : 428

Determines if the instance is tomorrow.

`public isTomorrow() : bool`

##### Tags

example

      Carbon::tomorrow()->isTomorrow(); // true
      Carbon::yesterday()->isTomorrow(); // false

##### Return values

bool

#### isWeekday()

Comparison.php : 366

Determines if the instance is a weekday.

`public isWeekday() : bool`

##### Tags

example

      Carbon::parse('2019-07-14')->isWeekday(); // false
      Carbon::parse('2019-07-15')->isWeekday(); // true

##### Return values

bool

#### isWeekend()

Comparison.php : 380

Determines if the instance is a weekend day.

`public isWeekend() : bool`

##### Tags

example

      Carbon::parse('2019-07-14')->isWeekend(); // true
      Carbon::parse('2019-07-15')->isWeekend(); // false

##### Return values

bool

#### isYesterday()

Comparison.php : 398

Determines if the instance is yesterday.

`public isYesterday() : bool`

##### Tags

example

      Carbon::yesterday()->isYesterday(); // true
      Carbon::tomorrow()->isYesterday(); // false

##### Return values

bool

#### lessThan()

Comparison.php : 222

Determines if the instance is less (before) than another

`public lessThan(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:15'); // false
      Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->lessThan('2018-07-25 12:45:17'); // true

##### Return values

bool

#### lessThanOrEqualTo()

Comparison.php : 271

Determines if the instance is less (before) or equal to another

`public lessThanOrEqualTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:15'); // false
      Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:16'); // true
      Carbon::parse('2018-07-25 12:45:16')->lessThanOrEqualTo('2018-07-25 12:45:17'); // true

##### Return values

bool

#### lt()

Comparison.php : 207

Determines if the instance is less (before) than another

`public lt(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:15'); // false
      Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->lt('2018-07-25 12:45:17'); // true

see
  lessThan()

##### Return values

bool

#### lte()

Comparison.php : 256

Determines if the instance is less (before) or equal to another

`public lte(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:15'); // false
      Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:16'); // true
      Carbon::parse('2018-07-25 12:45:16')->lte('2018-07-25 12:45:17'); // true

see
  lessThanOrEqualTo()

##### Return values

bool

#### ne()

Comparison.php : 94

Determines if the instance is not equal to another

`public ne(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->ne(Carbon::parse('2018-07-25 12:45:16')); // false
      Carbon::parse('2018-07-25 12:45:16')->ne('2018-07-25 12:45:17'); // true

see
  notEqualTo()

##### Return values

bool

#### notEqualTo()

Comparison.php : 109

Determines if the instance is not equal to another

`public notEqualTo(DateTimeInterface|string $date) : bool`

##### Parameters

$date : DateTimeInterface|string

##### Tags

example

      Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:16'); // false
      Carbon::parse('2018-07-25 12:45:16')->notEqualTo(Carbon::parse('2018-07-25 12:45:16')); // false
      Carbon::parse('2018-07-25 12:45:16')->notEqualTo('2018-07-25 12:45:17'); // true

##### Return values

bool

#### nowWithSameTz()

Comparison.php : 0
`public static nowWithSameTz() : void`

#### resolveCarbon()

Comparison.php : 0
`public static resolveCarbon(mixed $date) : void`

##### Parameters

$date : mixed

#### tomorrow()

Comparison.php : 0
`public static tomorrow(mixed $timezone) : static`

##### Parameters

$timezone : mixed

##### Return values

static

#### yesterday()

Comparison.php : 0
`public static yesterday(mixed $timezone) : static`

##### Parameters

$timezone : mixed

##### Return values

static

## Search results