Syntax: - Object Oriented Style:
bool IntlCalendar::equals (IntlCalendar $other)
- Procedural style:
bool intlcal_equals (IntlCalendar $cal, IntlCalendar $other)
Parameters : - $cal:this parameter contains IntlCalendar resource.
- $other:This parameter contains 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 objects is the same, otherwise it returns FALSE.The following program illustrates the IntlCalendar::equals() function in PHP:
Program : Php
// Create 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 the IntlCalendar::equals() function to compare the time
// from two IntlCalendar objects and displaying the result
var_dump (
$calendar1
-> equals (
$calendar2
));
// Clone DateTime $calendar1
$calendar2
=
clone
$calendar1
;
// Use the IntlCalendar::equals() function to compare the time
// from two IntlCalendar objects and displaying the result
var_dump (
$calendar1
-> equals (
$calendar2
));
// Create an IntlCalendar instance
$calendar2
= IntlCalendar::createInstance (NULL,
’en_US’
);
// Set DateTime $calendar2 to $calendar1
$calendar2
-> setTime (
$calendar1
-> getTime());
// Use the IntlCalendar::equals() function to compare the time
// from two IntlCalendar objects and displaying the result
var_dump (
$calendar1
-> equals (
$calendar2
));
// Clone DateTime $calendar1
$calendar2
=
clone
$calendar1
;
// Set DateTime $calendar2 to $calendar1
$calendar2
-> setTime (
$calendar1
-> getTime() - 10);
// Use the IntlCalendar::equals() function to compare the time
// from two IntlCalendar objects and displaying the result
var_dump (
$calendar1
-> equals (
$calendar2
));
?>
Exit:bool (false ) bool (true) bool (true) bool (false)
Link: https://www.php.net/manual/en/intlcalendar.equals.php