Tuesday, October 7, 2025
HomeLanguagesPHP | IntlCalendar isEquivalentTo() Function

PHP | IntlCalendar isEquivalentTo() Function

The IntlCalendar::isEquivalentTo() function is an inbuilt function in PHP which is used to check whether the given calendar is equal but for a different time.

Syntax:

  • Object oriented style
    bool IntlCalendar::isEquivalentTo( IntlCalendar $other )
  • Procedural style
    bool intlcal_is_equivalent_to( IntlCalendar $cal, IntlCalendar $other )

Parameters: This function uses two parameters as mentioned above and described below:

  • $cal: This parameter holds the resource of IntlCalendar object.
  • $other: This parameter holds the another calendar against which the comparison is to be perform.

Return Value: This function returns TRUE if calendars are equivalent except possibly for their set time and return an error if the value of the parameter is not set.

Below program illustrates the IntlCalendar::isEquivalentTo() function in PHP:

Program:




<?php
  
// Set the DateTime zone
ini_set('date.timezone', 'Asia/Calcutta');
  
// Create an instance of IntlCalendar
$calendar1 = IntlCalendar::createInstance('Asia/Calcutta');
  
// Create an instance of another IntlCalendar
$calendar2 = IntlCalendar::createInstance();
  
// Check whether another calendar is equal
// but for a different time
var_dump($calendar1->isEquivalentTo($calendar2));
  
// Create a DateTime object
$calendar1 = IntlCalendar::fromDateTime('2019-09-24');
  
// Set the date to another DateTime object
$calendar2->set(2019, 8, 24);
  
// Check whether another calendar is equal
// but for a different time
var_dump($calendar1->isEquivalentTo($calendar2));
  
?>


Output:

bool(true)
bool(true)

Reference: https://www.php.net/manual/en/intlcalendar.isequivalentto.php

RELATED ARTICLES

Most Popular

Dominic
32340 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6708 POSTS0 COMMENTS
Nicole Veronica
11872 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6829 POSTS0 COMMENTS
Ted Musemwa
7090 POSTS0 COMMENTS
Thapelo Manthata
6780 POSTS0 COMMENTS
Umr Jansen
6784 POSTS0 COMMENTS