$days
$days : array
Names of days of the week.
Provides a suite of modifier methods.
These methods let you modify the various aspects of a DateTime with a series of fluent methods.
This trait expects that the implementing class also implements a copy() method. This method can be obtained using the CopyTrait.
setDateTime(integer $year, integer $month, integer $day, integer $hour, integer $minute, integer $second) : static
Set the date and time all together
integer | $year | The year to set. |
integer | $month | The month to set. |
integer | $day | The day to set. |
integer | $hour | The hour to set. |
integer | $minute | The minute to set. |
integer | $second | The second to set. |
addMonths(integer $value) : static
Add months to the instance. Positive $value travels forward while negative $value travels into the past.
When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.
(new Chronos('2015-01-03'))->addMonths(1); // Results in 2015-02-03
(new Chronos('2015-01-31'))->addMonths(1); // Results in 2015-02-28
integer | $value | The number of months to add. |
addMonth(integer $value = 1) : static
Add a month to the instance
When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.
(new Chronos('2015-01-03'))->addMonth(); // Results in 2015-02-03
(new Chronos('2015-01-31'))->addMonth(); // Results in 2015-02-28
integer | $value | The number of months to add. |
subMonth(integer $value = 1) : static
Remove a month from the instance
When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.
(new Chronos('2015-03-01'))->subMonth(); // Results in 2015-02-01
(new Chronos('2015-03-31'))->subMonth(); // Results in 2015-02-28
integer | $value | The number of months to remove. |
subMonths(integer $value) : static
Remove months from the instance
When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.
(new Chronos('2015-03-01'))->subMonths(1); // Results in 2015-02-01
(new Chronos('2015-03-31'))->subMonths(1); // Results in 2015-02-28
integer | $value | The number of months to remove. |
next(integer|null $dayOfWeek = null) : mixed
Modify to the next occurrence of a given day of the week.
If no dayOfWeek is provided, modify to the next occurrence of the current day of the week. Use the supplied consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
previous(integer|null $dayOfWeek = null) : mixed
Modify to the previous occurrence of a given day of the week.
If no dayOfWeek is provided, modify to the previous occurrence of the current day of the week. Use the supplied consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
firstOfMonth(integer|null $dayOfWeek = null) : mixed
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 consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
lastOfMonth(integer|null $dayOfWeek = null) : mixed
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 consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
nthOfMonth(integer $nth, integer $dayOfWeek) : 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.
Use the supplied consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer | $nth | The offset to use. |
integer | $dayOfWeek | The day of the week to move to. |
firstOfQuarter(integer|null $dayOfWeek = null) : mixed
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 consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
lastOfQuarter(integer|null $dayOfWeek = null) : mixed
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 consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
nthOfQuarter(integer $nth, integer $dayOfWeek) : 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.
Use the supplied consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer | $nth | The offset to use. |
integer | $dayOfWeek | The day of the week to move to. |
firstOfYear(integer|null $dayOfWeek = null) : mixed
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 consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
lastOfYear(integer|null $dayOfWeek = null) : mixed
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 consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer|null | $dayOfWeek | The day of the week to move to. |
nthOfYear(integer $nth, integer $dayOfWeek) : 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.
Use the supplied consts to indicate the desired dayOfWeek, ex. ChronosInterface::MONDAY.
integer | $nth | The offset to use. |
integer | $dayOfWeek | The day of the week to move to. |
average(\Cake\Chronos\ChronosInterface|null $dt = null) : static
Modify the current instance to the average of a given instance (default now) and the current instance.
\Cake\Chronos\ChronosInterface|null | $dt | The instance to compare with. |