PHP | IntlCalendar equals() Function Last Updated : 03 Sep, 2019 Comments Improve Suggest changes Like Article Like Report The IntlCalendar::equals() function is an inbuilt function in PHP which is used to compare two IntlCalendar time objects and returns true if this calendar and given calendar have same date otherwise returns false. Syntax: Object oriented style: bool IntlCalendar::equals( IntlCalendar $other ) Procedural style: bool intlcal_equals( IntlCalendar $cal, IntlCalendar $other ) Parameters: $cal: This parameter holds the IntlCalendar resource. $other: This parameter holds the calendar date and time to compare with the first time object. Return Value: This function returns TRUE if the current time of both IntlCalendar object are same otherwise returns FALSE. Below program illustrates the IntlCalendar::equals() function in PHP: Program: php <?php // Create an IntlCalendar from a DateTime object or string $calendar1 = IntlCalendar::fromDateTime('2019-03-21 09:19:29'); $calendar2 = IntlCalendar::fromDateTime('2018-03-21 09:19:29'); // Use IntlCalendar::equals() function to compare time // of two IntlCalendar objects and display result var_dump($calendar1->equals($calendar2)); // Clone the DateTime of $calendar1 $calendar2 = clone $calendar1; // Use IntlCalendar::equals() function to compare time // of two IntlCalendar objects and display result var_dump($calendar1->equals($calendar2)); // Create an instance of IntlCalendar $calendar2 = IntlCalendar::createInstance(NULL, 'en_US'); // Set DateTime of $calendar2 to $calendar1 $calendar2->setTime($calendar1->getTime()); // Use IntlCalendar::equals() function to compare time // of two IntlCalendar objects and display result var_dump($calendar1->equals($calendar2)); // Clone the DateTime of $calendar1 $calendar2 = clone $calendar1; // Set DateTime of $calendar2 to $calendar1 $calendar2->setTime($calendar1->getTime() - 10); // Use IntlCalendar::equals() function to compare time // of two IntlCalendar objects and display result var_dump($calendar1->equals($calendar2)); ?> Output: bool(false) bool(true) bool(true) bool(false) Reference: https://www.php.net/manual/en/intlcalendar.equals.php Comment More infoAdvertise with us Next Article PHP | IntlCalendar equals() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Intl Similar Reads PHP | IntlCalendar add() Function The IntlCalendar::add() function is an inbuilt function in PHP which is used to add a signed amount of time to a field. Syntax: Object oriented style: bool IntlCalendar::add( int $field, int $amount ) Procedural style: bool intlcal_add( IntlCalendar $cal, int $field, int $amount ) Parameters: $cal: 2 min read PHP | IntlCalendar after() Function The IntlCalendar::after() function is an inbuilt function in PHP which returns True if the object time is after that of the passed object. Syntax: Object oriented style:bool IntlCalendar::after( IntlCalendar $other )Procedural style:bool intlcal_after( IntlCalendar $cal, IntlCalendar $other ) Parame 1 min read PHP | IntlCalendar before() Function The IntlCalendar::before() function is an inbuilt function in PHP which returns True if the object current time is before that of the passed object. Syntax: Object oriented style: bool IntlCalendar::before( IntlCalendar $other ) Procedural style: bool intlcal_before( IntlCalendar $cal, IntlCalendar 1 min read PHP | IntlCalendar get() Function The IntlCalendar::get() function is an inbuilt function in PHP which is used to get the value for a specific field. Syntax: Object oriented style int IntlCalendar::get( int $field ) Procedural style int intlcal_get( IntlCalendar $cal, int $field ) Parameters: This function uses two parameters as men 2 min read PHP | IntlCalendar set() Function The IntlCalendar::set() function is an inbuilt function in PHP which is used to set the time field or several common fields at once. The range of field value depends on the calendar. This function can not be called with exactly four parameters. Syntax: Object oriented style bool IntlCalendar::set( i 2 min read Like