INTLCAL_GET_ERROR_CODE(3) 1 INTLCAL_GET_ERROR_CODE(3)IntlCalendar::getErrorCode - Get last error code on the object
Object oriented style (method):
SYNOPSIS
public int IntlCalendar::getErrorCode (void )
DESCRIPTION
Procedural style:
int intlcal_get_error_code (IntlCalendar $calendar)
Returns the numeric ICU error code for the last call on this object (including cloning) or the IntlCalendar given for the $calendar param-
eter (in the proceduralstyle version). This may indicate only a warning (negative error code) or no error at all ( U_ZERO_ERROR). The
actual presence of an error can be tested with intl_is_failure(3).
Invalid arguments detected on the PHP side (before invoking functions of the ICU library) are not recorded for the purposes of this func-
tion.
The last error that occurred in any call to a function of the intl extension, including early argument errors, can be obtained with
intl_get_error_code(3). This function resets the global error code, but not the objects error code.
PARAMETERS
o $calendar
- The calendar object, on the procedural style interface.
RETURN VALUES
An ICU error code indicating either success, failure or a warning.
EXAMPLES
Example #1
intlcal_get_error_code(3) and IntlCalendar.getErrorMessage(3)
<?php
ini_set("intl.error_level", E_WARNING);
ini_set("intl.default_locale", "nl");
$intlcal = new IntlGregorianCalendar(2012, 1, 29);
var_dump(
$intlcal->getErrorCode(),
$intlcal->getErrorMessage()
);
$intlcal->fieldDifference(-1e100, IntlCalendar::FIELD_SECOND);
var_dump(
$intlcal->getErrorCode(),
$intlcal->getErrorMessage()
);
The above example will output:
int(0)string(12) "U_ZERO_ERROR"
Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in /home/glopes/php/ws/example.php on line 10
int(1)string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
SEE ALSO
IntlCalendar::getErrorMessage, intl_is_failure, intl_error_name, intl_get_error_code, intl_get_error_message.
PHP Documentation Group INTLCAL_GET_ERROR_CODE(3)
Check Out this Related Man Page
DATEFMT_FORMAT_OBJECT(3) 1 DATEFMT_FORMAT_OBJECT(3)IntlDateFormatter::formatObject - Formats an object
Object oriented style
SYNOPSIS
publicstatic string IntlDateFormatter::formatObject (object $object, [mixed $format = NULL], [string $locale = NULL])
DESCRIPTION
Procedural style string datefmt_format_object (object $object, [mixed $format = NULL], [string $locale = NULL])
This function allows formatting an IntlCalendar or DateTime object without first explicitly creating a IntlDateFormatter object.
The temporary IntlDateFormatter that will be created will take the timezone from the passed in object. The timezone database bundled with
PHP will not be used - ICU's will be used instead. The timezone identifier used in DateTime objects must therefore also exist in ICU's
database.
PARAMETERS
o $object
- An object of type IntlCalendar or DateTime. The timezone information in the object will be used.
o $format
- How to format the date/time. This can either be an array with two elements (first the date style, then the time style, these
being one of the constants IntlDateFormatter::NONE, IntlDateFormatter::SHORT, IntlDateFormatter::MEDIUM, IntlDateFormatter::LONG,
IntlDateFormatter::FULL), a long with the value of one of these constants (in which case it will be used both for the time and the
date) or a string with the format described in the ICU documentation. If NULL, the default style will be used.
o $locale
- The locale to use, or NULL to use the default one.
RETURN VALUES
A string with result or FALSE on failure.
EXAMPLES
Example #1
datefmt_format_object(3) examples
<?php
/* default timezone is irrelevant; timezone taken from the object */
ini_set('date.timezone', 'UTC');
/* default locale is taken from this ini setting */
ini_set('intl.default_locale', 'fr_FR');
$cal = IntlCalendar::fromDateTime("2013-06-06 17:05:06 Europe/Dublin");
echo "default:
",
IntlDateFormatter::formatObject($cal),
"
";
echo "long $format (full):
",
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL),
"
";
echo "array $format (none, full):
",
IntlDateFormatter::formatObject($cal, array(
IntlDateFormatter::NONE,
IntlDateFormatter::FULL)),
"
";
echo "string $format (d 'of' MMMM y):
",
IntlDateFormatter::formatObject($cal, "d 'of' MMMM y", 'en_US'),
"
";
echo "with DateTime:
",
IntlDateFormatter::formatObject(
new DateTime("2013-09-09 09:09:09 Europe/Madrid"),
IntlDateFormatter::FULL,
'es_ES'),
"
";
The above example will output:
default:
6 juin 2013 17:05:06
long $format (full):
jeudi 6 juin 2013 17:05:06 heure d'ete irlandaise
array $format (none, full):
17:05:06 heure d'ete irlandaise
string $format (d 'of' MMMM y):
6 of June 2013
with DateTime:
lunes, 9 de septiembre de 2013 09:09:09 Hora de verano de Europa central
PHP Documentation Group DATEFMT_FORMAT_OBJECT(3)