Fr3nch13/CakePHP Utilities

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

getWeekendDays()

Get weekend days

public static getWeekendDays() : array<string|int, mixed>
Return values
array<string|int, mixed>

greaterThanOrEquals()

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
bool

gt()

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
bool

gte()

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
bool

isBirthday()

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
bool

isFriday()

Checks if this day is a Friday.

public isFriday() : bool
Return values
bool

isFuture()

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

public isFuture() : bool
Return values
bool

isLastMonth()

Determines if the instance is within the last month

public isLastMonth() : bool
Return values
bool

isLastWeek()

Determines if the instance is within the last week

public isLastWeek() : bool
Return values
bool

isLastYear()

Determines if the instance is within the last year

public isLastYear() : bool
Return values
bool

isLeapYear()

Determines if the instance is a leap year

public isLeapYear() : bool
Return values
bool

isMonday()

Checks if this day is a Monday.

public isMonday() : bool
Return values
bool

isMutable()

Check if instance of ChronosInterface is mutable.

public isMutable() : bool
Return values
bool

isNextMonth()

Determines if the instance is within the next month

public isNextMonth() : bool
Return values
bool

isNextWeek()

Determines if the instance is within the next week

public isNextWeek() : bool
Return values
bool

isNextYear()

Determines if the instance is within the next year

public isNextYear() : bool
Return values
bool

isPast()

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

public isPast() : bool
Return values
bool

isSaturday()

Checks if this day is a Saturday.

public isSaturday() : bool
Return values
bool

isSunday()

Checks if this day is a Sunday.

public isSunday() : bool
Return values
bool

isThisMonth()

Returns true if this object represents a date within the current month

public isThisMonth() : bool
Return values
bool

isThisWeek()

Returns true if this object represents a date within the current week

public isThisWeek() : bool
Return values
bool

isThisYear()

Returns true if this object represents a date within the current year

public isThisYear() : bool
Return values
bool

isThursday()

Checks if this day is a Thursday.

public isThursday() : bool
Return values
bool

isToday()

Determines if the instance is today

public isToday() : bool
Return values
bool

isTomorrow()

Determines if the instance is tomorrow

public isTomorrow() : bool
Return values
bool

isTuesday()

Checks if this day is a Tuesday.

public isTuesday() : bool
Return values
bool

isWednesday()

Checks if this day is a Wednesday.

public isWednesday() : bool
Return values
bool

isWeekday()

Determines if the instance is a weekday

public isWeekday() : bool
Return values
bool

isWeekend()

Determines if the instance is a weekend day

public isWeekend() : bool
Return values
bool

isWithinNext()

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
bool

isYesterday()

Determines if the instance is yesterday

public isYesterday() : bool
Return values
bool

lte()

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
bool

setWeekendDays()

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.

Return values
bool

        
On this page

Search results