ComparisonTrait
Provides various comparison operator methods for datetime objects.
Table of Contents
Properties
- $weekendDays : array<string|int, mixed>
- Days of weekend
Methods
- between() : bool
- Determines if the instance is between two others
- closest() : ChronosInterface
- Get the closest date from the instance.
- eq() : bool
- Determines if the instance is equal to another
- equals() : bool
- Determines if the instance is equal to another
- farthest() : ChronosInterface
- Get the farthest date from the instance.
- getWeekendDays() : array<string|int, mixed>
- Get weekend days
- greaterThan() : bool
- Determines if the instance is greater (after) than another
- greaterThanOrEquals() : 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
- isBirthday() : bool
- Check if its the birthday. Compares the date/month values of the two dates.
- isFriday() : bool
- Checks if this day is a Friday.
- isFuture() : bool
- Determines if the instance is in the future, ie. greater (after) than now
- isLastMonth() : bool
- Determines if the instance is within the last month
- isLastWeek() : bool
- Determines if the instance is within the last week
- isLastYear() : bool
- Determines if the instance is within the last year
- isLeapYear() : bool
- Determines if the instance is a leap year
- isMonday() : bool
- Checks if this day is a Monday.
- isMutable() : bool
- Check if instance of ChronosInterface is mutable.
- isNextMonth() : bool
- Determines if the instance is within the next month
- isNextWeek() : bool
- Determines if the instance is within the next week
- isNextYear() : bool
- Determines if the instance is within the next year
- isPast() : bool
- Determines if the instance is in the past, ie. less (before) than now
- isSameDay() : bool
- Checks if the passed in date is the same day as the instance current day.
- isSaturday() : bool
- Checks if this day is a Saturday.
- isSunday() : bool
- Checks if this day is a Sunday.
- isThisMonth() : bool
- Returns true if this object represents a date within the current month
- isThisWeek() : bool
- Returns true if this object represents a date within the current week
- isThisYear() : bool
- Returns true if this object represents a date within the current year
- isThursday() : bool
- Checks if this day is a Thursday.
- isToday() : bool
- Determines if the instance is today
- isTomorrow() : bool
- Determines if the instance is tomorrow
- isTuesday() : bool
- Checks if this day is a Tuesday.
- isWednesday() : bool
- Checks if this day is a Wednesday.
- isWeekday() : bool
- Determines if the instance is a weekday
- isWeekend() : bool
- Determines if the instance is a weekend day
- isWithinNext() : bool
- Returns true this instance will happen within the specified interval
- isYesterday() : bool
- Determines if the instance is yesterday
- lessThan() : bool
- Determines if the instance is less (before) than another
- lessThanOrEquals() : 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
- max() : ChronosInterface
- Get the maximum instance between a given instance (default now) and the current instance.
- min() : ChronosInterface
- Get the minimum instance between a given instance (default now) and the current instance.
- ne() : bool
- Determines if the instance is not equal to another
- notEquals() : bool
- Determines if the instance is not equal to another
- setWeekendDays() : void
- Set weekend days
- wasWithinLast() : bool
- Returns true this instance happened within the specified interval
Properties
$weekendDays
Days of weekend
protected
static array<string|int, mixed>
$weekendDays
= [\Cake\Chronos\ChronosInterface::SATURDAY, \Cake\Chronos\ChronosInterface::SUNDAY]
Methods
between()
Determines if the instance is between two others
public
between(ChronosInterface $dt1, ChronosInterface $dt2[, bool $equal = true ]) : bool
Parameters
- $dt1 : ChronosInterface
-
The instance to compare with.
- $dt2 : ChronosInterface
-
The instance to compare with.
- $equal : bool = true
-
Indicates if a > and < comparison should be used or <= or >=
Return values
boolclosest()
Get the closest date from the instance.
public
closest(ChronosInterface $dt1, ChronosInterface $dt2) : ChronosInterface
Parameters
- $dt1 : ChronosInterface
-
The instance to compare with.
- $dt2 : ChronosInterface
-
The instance to compare with.
Return values
ChronosInterfaceeq()
Determines if the instance is equal to another
public
eq(ChronosInterface $dt) : bool
eq() is deprecated. Use equals() instead.
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolequals()
Determines if the instance is equal to another
public
equals(ChronosInterface $dt) : bool
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolfarthest()
Get the farthest date from the instance.
public
farthest(ChronosInterface $dt1, ChronosInterface $dt2) : ChronosInterface
Parameters
- $dt1 : ChronosInterface
-
The instance to compare with.
- $dt2 : ChronosInterface
-
The instance to compare with.
Return values
ChronosInterfacegetWeekendDays()
Get weekend days
public
static getWeekendDays() : array<string|int, mixed>
Return values
array<string|int, mixed>greaterThan()
Determines if the instance is greater (after) than another
public
greaterThan(ChronosInterface $dt) : bool
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolgreaterThanOrEquals()
Determines if the instance is greater (after) than or equal to another
public
greaterThanOrEquals(ChronosInterface $dt) : bool
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolgt()
Determines if the instance is greater (after) than another
public
gt(ChronosInterface $dt) : bool
gt() is deprecated. Use greaterThan() instead.
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolgte()
Determines if the instance is greater (after) than or equal to another
public
gte(ChronosInterface $dt) : bool
gte() is deprecated. Use greaterThanOrEquals() instead.
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolisBirthday()
Check if its the birthday. Compares the date/month values of the two dates.
public
isBirthday([ChronosInterface|null $dt = null ]) : bool
Parameters
- $dt : ChronosInterface|null = null
-
The instance to compare with or null to use current day.
Return values
boolisFriday()
Checks if this day is a Friday.
public
isFriday() : bool
Return values
boolisFuture()
Determines if the instance is in the future, ie. greater (after) than now
public
isFuture() : bool
Return values
boolisLastMonth()
Determines if the instance is within the last month
public
isLastMonth() : bool
Return values
boolisLastWeek()
Determines if the instance is within the last week
public
isLastWeek() : bool
Return values
boolisLastYear()
Determines if the instance is within the last year
public
isLastYear() : bool
Return values
boolisLeapYear()
Determines if the instance is a leap year
public
isLeapYear() : bool
Return values
boolisMonday()
Checks if this day is a Monday.
public
isMonday() : bool
Return values
boolisMutable()
Check if instance of ChronosInterface is mutable.
public
isMutable() : bool
Return values
boolisNextMonth()
Determines if the instance is within the next month
public
isNextMonth() : bool
Return values
boolisNextWeek()
Determines if the instance is within the next week
public
isNextWeek() : bool
Return values
boolisNextYear()
Determines if the instance is within the next year
public
isNextYear() : bool
Return values
boolisPast()
Determines if the instance is in the past, ie. less (before) than now
public
isPast() : bool
Return values
boolisSameDay()
Checks if the passed in date is the same day as the instance current day.
public
isSameDay(ChronosInterface $dt) : bool
Parameters
- $dt : ChronosInterface
-
The instance to check against.
Return values
boolisSaturday()
Checks if this day is a Saturday.
public
isSaturday() : bool
Return values
boolisSunday()
Checks if this day is a Sunday.
public
isSunday() : bool
Return values
boolisThisMonth()
Returns true if this object represents a date within the current month
public
isThisMonth() : bool
Return values
boolisThisWeek()
Returns true if this object represents a date within the current week
public
isThisWeek() : bool
Return values
boolisThisYear()
Returns true if this object represents a date within the current year
public
isThisYear() : bool
Return values
boolisThursday()
Checks if this day is a Thursday.
public
isThursday() : bool
Return values
boolisToday()
Determines if the instance is today
public
isToday() : bool
Return values
boolisTomorrow()
Determines if the instance is tomorrow
public
isTomorrow() : bool
Return values
boolisTuesday()
Checks if this day is a Tuesday.
public
isTuesday() : bool
Return values
boolisWednesday()
Checks if this day is a Wednesday.
public
isWednesday() : bool
Return values
boolisWeekday()
Determines if the instance is a weekday
public
isWeekday() : bool
Return values
boolisWeekend()
Determines if the instance is a weekend day
public
isWeekend() : bool
Return values
boolisWithinNext()
Returns true this instance will happen within the specified interval
public
isWithinNext(string|int $timeInterval) : bool
Parameters
- $timeInterval : string|int
-
the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.
Return values
boolisYesterday()
Determines if the instance is yesterday
public
isYesterday() : bool
Return values
boollessThan()
Determines if the instance is less (before) than another
public
lessThan(ChronosInterface $dt) : bool
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boollessThanOrEquals()
Determines if the instance is less (before) or equal to another
public
lessThanOrEquals(ChronosInterface $dt) : bool
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boollt()
Determines if the instance is less (before) than another
public
lt(ChronosInterface $dt) : bool
lt() is deprecated. Use lessThan instead.
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boollte()
Determines if the instance is less (before) or equal to another
public
lte(ChronosInterface $dt) : bool
lte() is deprecated. Use lessThanOrEquals() instead.
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolmax()
Get the maximum instance between a given instance (default now) and the current instance.
public
max([ChronosInterface|null $dt = null ]) : ChronosInterface
Parameters
- $dt : ChronosInterface|null = null
-
The instance to compare with.
Return values
ChronosInterfacemin()
Get the minimum instance between a given instance (default now) and the current instance.
public
min([ChronosInterface|null $dt = null ]) : ChronosInterface
Parameters
- $dt : ChronosInterface|null = null
-
The instance to compare with.
Return values
ChronosInterfacene()
Determines if the instance is not equal to another
public
ne(ChronosInterface $dt) : bool
ne() is deprecated. Use notEquals() instead.
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolnotEquals()
Determines if the instance is not equal to another
public
notEquals(ChronosInterface $dt) : bool
Parameters
- $dt : ChronosInterface
-
The instance to compare with.
Return values
boolsetWeekendDays()
Set weekend days
public
static setWeekendDays(array<string|int, mixed> $days) : void
Parameters
- $days : array<string|int, mixed>
-
Which days are 'weekends'.
wasWithinLast()
Returns true this instance happened within the specified interval
public
wasWithinLast(string|int $timeInterval) : bool
Parameters
- $timeInterval : string|int
-
the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.