Syntax: Parameters:This function uses one parameter,
$calendar,which contains the calendar object in the procedural style interface.
Return value: this function returns an ICU error code that indicates either success, failure, or warning.The following program illustrates the IntlCalendar::getErrorCode() function in PHP:
Program:
// Set the DateTime zone
ini_set
(
’date.timezone’
,
’ Asia / Calcutta’
);
// Set intl error level
ini_set
(
"intl.error_level"
, E_WARNING);
// Declare a DateTime object and store it in a variable
$calendar
= IntlCalendar::fromDateTime (
’2019- 03-21 09: 19: 29’
);
// Display the error code and message
var_dump (
$calendar
-> getErrorCode(),
$calendar
-> getErrorMessage()
);
// Declare a DateTime object and store it in a variable
$calendar
-> fieldDifference (-34E403, IntlCalendar::FIELD_ZONE_OFFSET);
// Display the error code and message
var_dump (
$calendar
-> getErrorCode(),
$calendar
-> getErrorMessage()
);
?>
Exit:PHP Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in /home/d0608573e6cb44f285316ff59fb833b0.php on line 19 int (0) string (12) "U_ZERO_ERROR" int (1) string (81) "intlcal_field_difference" intlcal_field_difference method has failed: U_ILLEGAL_ARGUMENT_ERROR "
Link: https://www.php.net/manual/en/intlcalendar.geterrorcode.php