PHP | IntlCalendar getErrorMessage() Function

The IntlCalendar::getErrorMessage() function is an inbuilt function in PHP which is used to return the error message (if any error exist) associated with the error by using IntlCalendar::getErrorCode() or intlcal_get_error_code() function.

Syntax:

  • Object oriented style
    string IntlCalendar::getErrorMessage( void )
  • Procedural style
    string intlcal_get_error_message( IntlCalendar $calendar )

Parameters: This function uses single parameter $calendar which holds the calendar object on the procedural style interface.



Return Value: This function returns the error message which is associated with last error that occurred in a function call on this object or a string which indicates the non-existence of an error.

Below program illustrates the IntlCalendar::getErrorMessage() function in PHP:

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Set the DateTime zone
ini_set('date.timezone', 'Asia/Calcutta');
  
// Set the intl error level
ini_set("intl.error_level", E_WARNING);
  
// Declare a DateTime object and store it into variable
$calendar = IntlCalendar::fromDateTime('2019-03-21 09:19:29');
  
// Display the error code and message
var_dump($calendar->getErrorMessage());
  
// Declare a DateTime object and store it into variable
$calendar->fieldDifference(-34E403, IntlCalendar::FIELD_ZONE_OFFSET);
  
// Display the error code and message
var_dump($calendar->getErrorMessage());
  
?>

chevron_right


Output:

PHP Warning:  IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has
failed in /home/22bd84b151f5397224d747dadc65338e.php on line 16
string(12) "U_ZERO_ERROR"
string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"

Reference: https://www.php.net/manual/en/intlcalendar.geterrormessage.php



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.