PHP | IntlCalendar equals() Function
Last Updated :
03 Sep, 2019
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
$calendar1 = IntlCalendar::fromDateTime( '2019-03-21 09:19:29' );
$calendar2 = IntlCalendar::fromDateTime( '2018-03-21 09:19:29' );
var_dump( $calendar1 ->equals( $calendar2 ));
$calendar2 = clone $calendar1 ;
var_dump( $calendar1 ->equals( $calendar2 ));
$calendar2 = IntlCalendar::createInstance(NULL, 'en_US' );
$calendar2 ->setTime( $calendar1 ->getTime());
var_dump( $calendar1 ->equals( $calendar2 ));
$calendar2 = clone $calendar1 ;
$calendar2 ->setTime( $calendar1 ->getTime() - 10);
var_dump( $calendar1 ->equals( $calendar2 ));
?>
|
Output:
bool(false)
bool(true)
bool(true)
bool(false)
Reference: https://www.php.net/manual/en/intlcalendar.equals.php
Share your thoughts in the comments
Please Login to comment...