PHP | IntlCalendar roll() Function
The IntlCalendar::roll() function is an inbuilt function in PHP which is used to add value to field without carrying into more significant fields. The difference between IntlCalendar::roll() and IntlCalendar::add() function is that, the field value of IntlCalendar::roll() function overflow, it does not carry into more significant fields.
- Object oriented style
bool IntlCalendar::roll( int $field, mixed $amountOrUpOrDown )
- Procedural style
bool intlcal_roll( IntlCalendar $cal, int $field, mixed $amountOrUpOrDown )
- $cal: This parameter holds the resource of IntlCalendar object.
- $field: This parameter holds one of the IntlCalendar date/time field constants. The value of field constants are integer and lies between 0 to IntlCalendar::FIELD_COUNT.
- $amountOrUpOrDown: This parameter holds the signed amount to add to the field. The TRUE value represents rolling up (adding 1) and FALSE value represents rolling down (subtracting 1) from the DateTime field.
Return Value: This function returns TRUE on success or FALSE on failure.
Below program illustrates the IntlCalendar::roll() function in PHP:
string(24) "Sep 24, 2019, 8:29:48 AM" string(24) "Sep 23, 2019, 8:29:48 AM"