PHP | IntlDateFormatter getErrorCode() Function, Last Updated : 10 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The IntlDateFormatter::getErrorCode() function is an inbuilt function in PHP which is used to return the error code from last operation. Syntax: Object-oriented style: int IntlDateFormatter::getErrorCode( void ) Procedural style: int datefmt_get_error_code( IntlDateFormatter $fmt ) Parameters: This function uses a single parameter $fmt which holds the resource of formatter. Return Value: This function returns the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. Below program illustrates the IntlDateFormatter::getErrorCode() function in PHP: Program: php <?php // Create a date formatter $formatter = datefmt_create( 'en_US', IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, 'Asia/Kolkata', IntlDateFormatter::GREGORIAN ); // Format the date/time value // as a string $str = datefmt_format($formatter); if (!$str) { echo "Error code: " . datefmt_get_error_code($formatter) . "\n"; echo "Error message: " . datefmt_get_error_message($formatter); } echo "\n\n"; // Format the date/time value // as a string $str = $formatter->format("geeks"); if (!$str) { echo "Error code: " . $formatter->getErrorCode() . "\n"; echo "Error message: " . $formatter->getErrorMessage(); } ?> Error: PHP Warning: datefmt_format() expects exactly 2 parameters, 1 given in /home/700d8660f05cec95beb6e1ab21252ab1.php on line 14 Output: Error code: 0 Error message: U_ZERO_ERROR Error code: 1 Error message: datefmt_format: string 'geeks' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR Reference: https://www.php.net/manual/en/intldateformatter.geterrorcode.php Comment More infoAdvertise with us Next Article PHP | IntlDateFormatter getErrorCode() Function, J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Intl Similar Reads PHP | IntlDateFormatter getDateType() Function The IntlDateFormatter::getDateType() function is an inbuilt function in PHP which is used to get the datetype used for the IntlDateFormatter object. Syntax: Object oriented style: int IntlDateFormatter::getDateType( void ) Procedural style: int datefmt_get_datetype( IntlDateFormatter $fmt ) Paramete 2 min read PHP | IntlDateFormatter getCalendar() Function The IntlDateFormatter::getCalendar() function is an inbuilt function in PHP which is used to return the calendar type used for the IntlDateFormatter object.Syntax: Object oriented style: int IntlDateFormatter::getCalendar( void )Procedural style: int datefmt_get_calendar( IntlDateFormatter $fmt ) Pa 2 min read PHP | IntlCalendar getErrorCode() Function 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: Object orien 1 min read PHP | IntlDateFormatter format() Function The IntlDateFormatter::format() function is an inbuilt function in PHP which is used to format the date/time value as a string. Syntax: Object oriented style: string IntlDateFormatter::format( mixed $value ) Procedural style: string datefmt_format( IntlDateFormatter $fmt, mixed $value ) Parameters: 2 min read 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::getErrorM 1 min read Like