FileAccess Orion

Modifiers

Trait Modifiers.

Returns dates relative to current date using modifier short-hand.

Table of Contents

$midDayAt  : int
Midday/noon hour.
average()  : static
Modify the current instance to the average of a given instance (default now) and the current instance (second-precision).
change()  : static
Similar to native modify() method of DateTime but can handle more grammars.
closest()  : static
Get the closest date from the instance (second-precision).
farthest()  : static
Get the farthest date from the instance (second-precision).
firstOfMonth()  : static
Modify to the first occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the first day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
firstOfQuarter()  : static
Modify to the first occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the first day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
firstOfYear()  : static
Modify to the first occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the first day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
getMidDayAt()  : int
get midday/noon hour
lastOfMonth()  : static
Modify to the last occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the last day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
lastOfQuarter()  : static
Modify to the last occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the last day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
lastOfYear()  : static
Modify to the last occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the last day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
max()  : static
Get the maximum instance between a given instance (default now) and the current instance.
maximum()  : static
Get the maximum instance between a given instance (default now) and the current instance.
midDay()  : static
Modify to midday, default to self::$midDayAt
min()  : static
Get the minimum instance between a given instance (default now) and the current instance.
minimum()  : static
Get the minimum instance between a given instance (default now) and the current instance.
modify()  : mixed
Calls \DateTime::modify if mutable or \DateTimeImmutable::modify else.
next()  : static
Modify to the next occurrence of a given modifier such as a day of the week. If no modifier is provided, modify to the next occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
nextWeekday()  : static
Go forward to the next weekday.
nextWeekendDay()  : static
Go forward to the next weekend day.
nthOfMonth()  : mixed
Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside the scope of the current month, then return false and no modifications are made.
nthOfQuarter()  : mixed
Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside the scope of the current quarter, then return false and no modifications are made.
nthOfYear()  : mixed
Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside the scope of the current year, then return false and no modifications are made.
previous()  : static
Modify to the previous occurrence of a given modifier such as a day of the week. If no dayOfWeek is provided, modify to the previous occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
previousWeekday()  : static
Go backward to the previous weekday.
previousWeekendDay()  : static
Go backward to the previous weekend day.
setMidDayAt()  : void
nextOrPreviousDay()  : static
Go forward or backward to the next week- or weekend-day.

Properties

$midDayAt

Midday/noon hour.

protected static int $midDayAt = 12

Methods

average()

Modify the current instance to the average of a given instance (default now) and the current instance (second-precision).

public average([Carbon|DateTimeInterface|null $date = null ]) : static
Parameters
$date : Carbon|DateTimeInterface|null = null
Return values
static —

change()

Similar to native modify() method of DateTime but can handle more grammars.

public change(string $modifier) : static
Parameters
$modifier : string
Tags
example
echo Carbon::now()->change('next 2pm');
link
https://php.net/manual/en/datetime.modify.php
Return values
static —

closest()

Get the closest date from the instance (second-precision).

public closest(Carbon|DateTimeInterface|mixed $date1, Carbon|DateTimeInterface|mixed $date2) : static
Parameters
$date1 : Carbon|DateTimeInterface|mixed
$date2 : Carbon|DateTimeInterface|mixed
Return values
static —

farthest()

Get the farthest date from the instance (second-precision).

public farthest(Carbon|DateTimeInterface|mixed $date1, Carbon|DateTimeInterface|mixed $date2) : static
Parameters
$date1 : Carbon|DateTimeInterface|mixed
$date2 : Carbon|DateTimeInterface|mixed
Return values
static —

firstOfMonth()

Modify to the first occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the first day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public firstOfMonth([int|null $dayOfWeek = null ]) : static
Parameters
$dayOfWeek : int|null = null
Return values
static —

firstOfQuarter()

Modify to the first occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the first day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public firstOfQuarter([int|null $dayOfWeek = null ]) : static
Parameters
$dayOfWeek : int|null = null

day of the week default null

Return values
static —

firstOfYear()

Modify to the first occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the first day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public firstOfYear([int|null $dayOfWeek = null ]) : static
Parameters
$dayOfWeek : int|null = null

day of the week default null

Return values
static —

getMidDayAt()

get midday/noon hour

public static getMidDayAt() : int
Return values
int —

lastOfMonth()

Modify to the last occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the last day of the current month. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public lastOfMonth([int|null $dayOfWeek = null ]) : static
Parameters
$dayOfWeek : int|null = null
Return values
static —

lastOfQuarter()

Modify to the last occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the last day of the current quarter. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public lastOfQuarter([int|null $dayOfWeek = null ]) : static
Parameters
$dayOfWeek : int|null = null

day of the week default null

Return values
static —

lastOfYear()

Modify to the last occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the last day of the current year. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public lastOfYear([int|null $dayOfWeek = null ]) : static
Parameters
$dayOfWeek : int|null = null

day of the week default null

Return values
static —

max()

Get the maximum instance between a given instance (default now) and the current instance.

public max([Carbon|DateTimeInterface|mixed $date = null ]) : static
Parameters
$date : Carbon|DateTimeInterface|mixed = null
Return values
static —

maximum()

Get the maximum instance between a given instance (default now) and the current instance.

public maximum([Carbon|DateTimeInterface|mixed $date = null ]) : static
Parameters
$date : Carbon|DateTimeInterface|mixed = null
Tags
see
max()
Return values
static —

midDay()

Modify to midday, default to self::$midDayAt

public midDay() : static
Return values
static —

min()

Get the minimum instance between a given instance (default now) and the current instance.

public min([Carbon|DateTimeInterface|mixed $date = null ]) : static
Parameters
$date : Carbon|DateTimeInterface|mixed = null
Return values
static —

minimum()

Get the minimum instance between a given instance (default now) and the current instance.

public minimum([Carbon|DateTimeInterface|mixed $date = null ]) : static
Parameters
$date : Carbon|DateTimeInterface|mixed = null
Tags
see
min()
Return values
static —

next()

Modify to the next occurrence of a given modifier such as a day of the week. If no modifier is provided, modify to the next occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public next([string|int|null $modifier = null ]) : static
Parameters
$modifier : string|int|null = null
Return values
static —

nextWeekday()

Go forward to the next weekday.

public nextWeekday() : static
Return values
static —

nextWeekendDay()

Go forward to the next weekend day.

public nextWeekendDay() : static
Return values
static —

nthOfMonth()

Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside the scope of the current month, then return false and no modifications are made.

public nthOfMonth(int $nth, int $dayOfWeek) : mixed

Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters
$nth : int
$dayOfWeek : int
Return values
mixed —

nthOfQuarter()

Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside the scope of the current quarter, then return false and no modifications are made.

public nthOfQuarter(int $nth, int $dayOfWeek) : mixed

Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters
$nth : int
$dayOfWeek : int
Return values
mixed —

nthOfYear()

Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside the scope of the current year, then return false and no modifications are made.

public nthOfYear(int $nth, int $dayOfWeek) : mixed

Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters
$nth : int
$dayOfWeek : int
Return values
mixed —

previous()

Modify to the previous occurrence of a given modifier such as a day of the week. If no dayOfWeek is provided, modify to the previous occurrence of the current day of the week. Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.

public previous([string|int|null $modifier = null ]) : static
Parameters
$modifier : string|int|null = null
Return values
static —

previousWeekday()

Go backward to the previous weekday.

public previousWeekday() : static
Return values
static —

previousWeekendDay()

Go backward to the previous weekend day.

public previousWeekendDay() : static
Return values
static —

setMidDayAt()

public static setMidDayAt(int $hour) : void
Parameters
$hour : int

midday hour

Tags
deprecated

To avoid conflict between different third-party libraries, static setters should not be used. You should rather consider mid-day is always 12pm, then if you need to test if it's an other hour, test it explicitly: $date->format('G') == 13 or to set explicitly to a given hour: $date->setTime(13, 0, 0, 0)

Set midday/noon hour

Return values
void —

nextOrPreviousDay()

Go forward or backward to the next week- or weekend-day.

private nextOrPreviousDay([bool $weekday = true ][, bool $forward = true ]) : static
Parameters
$weekday : bool = true
$forward : bool = true
Return values
static —

Search results