PHP | IntlCalendar getErrorCode() Function
Last Updated :
25 Sep, 2019
The IntlCalendar::getErrorCode() function is an inbuilt function in PHP which returns the numeric ICU error code for the last call on this object or the IntlCalendar given for the calendar parameter. This function can indicate a warning message (negative error code) or no error.
Syntax:
Parameters: This function uses single parameter $calendar which holds the calendar object on the procedural style interface.
Return Value: This function returns the ICU error code which indicates either success, failure or a warning message.
Below program illustrates the IntlCalendar::getErrorCode() function in PHP:
Program:
<?php
ini_set ( 'date.timezone' , 'Asia/Calcutta' );
ini_set ( "intl.error_level" , E_WARNING);
$calendar = IntlCalendar::fromDateTime( '2019-03-21 09:19:29' );
var_dump(
$calendar ->getErrorCode(),
$calendar ->getErrorMessage()
);
$calendar ->fieldDifference(-34E403, IntlCalendar::FIELD_ZONE_OFFSET);
var_dump(
$calendar ->getErrorCode(),
$calendar ->getErrorMessage()
);
?>
|
Output:
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: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
Reference: https://www.php.net/manual/en/intlcalendar.geterrorcode.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...