trait Modifiers
Trait Modifiers.
Returns dates relative to current date using modifier short-hand.
Properties
staticprotectedint | $midDayAt | Midday/noon hour. |
Methods
get midday/noon hour
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.
Go forward to the next weekday.
Go backward to the previous weekday.
Go forward to the next weekend day.
Go backward to the previous weekend day.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Modify the current instance to the average of a given instance (default now) and the current instance (second-precision).
Get the closest date from the instance (second-precision).
Get the farthest date from the instance (second-precision).
Get the minimum instance between a given instance (default now) and the current instance.
Get the minimum instance between a given instance (default now) and the current instance.
Get the maximum instance between a given instance (default now) and the current instance.
Get the maximum instance between a given instance (default now) and the current instance.
No description
Details
at line36
staticint
getMidDayAt()
get midday/noon hour
at line55
staticvoid
setMidDayAt(int$hour)deprecated
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
at line65
Modifiers
midDay()
Modify to midday, default to self::$midDayAt
at line80
Modifiers
next(string|int|null$modifier =null)
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.
at line117
Modifiers
nextWeekday()
Go forward to the next weekday.
at line127
Modifiers
previousWeekday()
Go backward to the previous weekday.
at line137
Modifiers
nextWeekendDay()
Go forward to the next weekend day.
at line147
Modifiers
previousWeekendDay()
Go backward to the previous weekend day.
at line162
Modifiers
previous(string|int|null$modifier =null)
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.
at line183
Modifiers
firstOfMonth(int|null$dayOfWeek =null)
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.
at line204
Modifiers
lastOfMonth(int|null$dayOfWeek =null)
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.
at line226
mixed
nthOfMonth(int$nth,int$dayOfWeek)
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.
Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
at line245
Modifiers
firstOfQuarter(int|null$dayOfWeek =null)
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.
at line260
Modifiers
lastOfQuarter(int|null$dayOfWeek =null)
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.
at line276
mixed
nthOfQuarter(int$nth,int$dayOfWeek)
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.
Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
at line296
Modifiers
firstOfYear(int|null$dayOfWeek =null)
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.
at line311
Modifiers
lastOfYear(int|null$dayOfWeek =null)
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.
at line327
mixed
nthOfYear(int$nth,int$dayOfWeek)
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.
Use the supplied constants to indicate the desired dayOfWeek, ex. static::MONDAY.
at line342
Modifiers
average(Carbon|DateTimeInterface|null$date =null)
Modify the current instance to the average of a given instance (default now) and the current instance (second-precision).
at line355
Modifiers
closest(Carbon|DateTimeInterface|mixed$date1,Carbon|DateTimeInterface|mixed$date2)
Get the closest date from the instance (second-precision).
at line368
Modifiers
farthest(Carbon|DateTimeInterface|mixed$date1,Carbon|DateTimeInterface|mixed$date2)
Get the farthest date from the instance (second-precision).
at line380
Modifiers
min(Carbon|DateTimeInterface|mixed$date =null)
Get the minimum instance between a given instance (default now) and the current instance.
at line396
Modifiers
minimum(Carbon|DateTimeInterface|mixed$date =null)
Get the minimum instance between a given instance (default now) and the current instance.
at line408
Modifiers
max(Carbon|DateTimeInterface|mixed$date =null)
Get the maximum instance between a given instance (default now) and the current instance.
at line424
Modifiers
maximum(Carbon|DateTimeInterface|mixed$date =null)
Get the maximum instance between a given instance (default now) and the current instance.
at line437
modify($modify)
at line456
Modifiers
change(string$modifier)
Similar to native modify() method of DateTime but can handle more grammars.