The 5th Annual China PHP Conference


(PHP 5.5.0, PECL >= 3.0.0a1)

IntlCalendar::equalsCompare time of two IntlCalendar objects for equality


Stile orientato agli oggetti

public bool IntlCalendar::equals ( IntlCalendar $other )

Stile procedurale

bool intlcal_equals ( IntlCalendar $cal , IntlCalendar $other )

Returns true if this calendar and the given calendar have the same time. The settings, calendar types and field states do not have to be the same.

Elenco dei parametri


The IntlCalendar resource.


The calendar to compare with the primary object.

Valori restituiti

Returns TRUE if the current time of both this and the passed in IntlCalendar object are the same, or FALSE otherwise. The value FALSE can also be returned on failure. This can only happen if bad arguments are passed in. In any case, the two cases can be distinguished by calling intl_get_error_code().


Example #1 IntlCalendar::equals()


$cal1 IntlCalendar::createInstance(NULL'es_ES');
$cal2 = clone $cal1;

var_dump($cal1->equals($cal2)); //TRUE

//The locale is not included in the comparison
$cal2 IntlCalendar::createInstance(NULL'pt_PT');
var_dump($cal1->equals($cal2)); //TRUE

//And set fields state is not included as well
var_dump($cal1->isSet(IntlCalendar::FIELD_YEAR) ==
$cal2->isSet(IntlCalendar::FIELD_YEAR)); //FALSE
var_dump($cal1->equals($cal2)); //TRUE

//Neither is the calendar type
$cal2 IntlCalendar::createInstance(NULL'es_ES@calendar=islamic');
var_dump($cal1->equals($cal2)); //TRUE

//Only the time is
$cal2 = clone $cal1;
$cal2->setTime($cal1->getTime() + 1.);
var_dump($cal1->equals($cal2)); //FALSE

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top