The IntlCalendar::isSet() function is an inbuilt function in PHP which is used to check whether a given field is set or not. This function is opposite to IntlCalendar::clear() function.
Syntax:
Parameters: This function uses two parameters as mentioned above and described below:
- $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.
Return Value: This function returns TRUE if the field is set and returns error if the field is not set.
Below program illustrates the IntlCalendar::isSet() function in PHP:
Program:
<?php
ini_set ( 'date.timezone' , 'Asia/Calcutta' );
$calendar = IntlCalendar::createInstance( 'Asia/Calcutta' );
var_dump( $calendar ->isSet(IntlCalendar::FIELD_MONTH));
$calendar ->set(2019, 8, 29);
var_dump( $calendar ->isSet(IntlCalendar::FIELD_MONTH));
$calendar ->set( strtotime ( '2019-09-22 12:30:00' ));
var_dump( $calendar ->isSet(IntlCalendar::FIELD_YEAR));
?>
|
Output:
bool(true)
bool(true)
bool(true)
Reference: https://www.php.net/manual/en/intlcalendar.isset.php