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 // 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)); ?> |
bool(false) bool(true) bool(true) bool(false)
Reference: https://www.php.net/manual/en/intlcalendar.equals.php
Recommended Posts:
- PHP | IntlCalendar add() Function
- PHP | IntlCalendar after() Function
- PHP | IntlCalendar before() Function
- PHP | IntlCalendar set() Function
- PHP | IntlCalendar get() Function
- PHP | IntlCalendar isEquivalentTo() Function
- PHP | IntlCalendar toDateTime() Function
- PHP | IntlCalendar setFirstDayOfWeek() Function
- PHP | IntlCalendar getActualMaximum() Function
- PHP | IntlCalendar getErrorCode() Function
- PHP | IntlCalendar getFirstDayOfWeek() Function
- PHP | IntlCalendar getActualMinimum() Function
- PHP | IntlCalendar getErrorMessage() Function
- PHP | IntlCalendar setTimeZone() Function
- PHP | IntlCalendar getAvailableLocales() Function
- PHP | IntlCalendar fromDateTime() Function
- PHP | IntlCalendar isSet() Function
- PHP | IntlCalendar isWeekend() Function
- PHP | IntlCalendar getType() Function
- PHP | IntlCalendar getTimeZone() Function
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.

