PHP | IntlCalendar createInstance() Function Last Updated : 28 Mar, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The IntlCalendar::createInstance() function is an inbuilt function in PHP which is used to create an instance of IntlCalendar. Syntax: Object oriented style: IntlCalendar IntlCalendar::createInstance( mixed $timeZone = NULL, string $locale = "" ) Procedural style: IntlCalendar intlcal_create_instance( mixed $timeZone = NULL, string $locale = "" ) Parameters: $timeZone: This parameter holds the used timezone. NULL: It is the default timezone. IntlTimeZone: It is used directly. DateTimeZone: It allows to set the timezone in DateTimeZone format. The identifier of DateTimeZone will be extracted and an ICU timezone object will be created. string: It is a valid ICU timezone identifier. $locale: This parameter holds the locale to use or NULL to use the default locale. Return Value: This function creates an IntlCalendar instance on success or NULL on failure. Below programs illustrate the IntlCalendar::createInstance() function in PHP: Program 1: php <?php // Create an IntlCalendar instance $calendar1 = IntlCalendar::createInstance(); // Create an IntlCalendar from a DateTime object or string $calendar2 = IntlCalendar::fromDateTime('2019-03-21 09:19:29'); // Use IntlCalendar::before() function var_dump($calendar1->before($calendar2)); var_dump($calendar2->before($calendar1)); // Use IntlCalendar::before() function var_dump($calendar1->after($calendar2)); var_dump($calendar2->after($calendar1)); ?> Output: bool(false) bool(true) bool(true) bool(false) Program 2: php <?php // Create an IntlCalendar from a DateTime object or string $calendar1 = IntlCalendar::fromDateTime('2019-03-21 09:19:29'); // 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 cCompare time // of two IntlCalendar objects and display result var_dump($calendar1->equals($calendar2)); ?> Output: bool(true) Reference: https://www.php.net/manual/en/intlcalendar.createinstance.php Comment More infoAdvertise with us Next Article PHP | IntlCalendar::__construct() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Intl Similar Reads PHP | IntlCalendar::__construct() Function The IntlCalendar::__construct() function is an inbuilt function in PHP which is used to create a private constructor for disallowing instantiation. Syntax: private IntlCalendar::__construct( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return 1 min read PHP | IntlCalendar fromDateTime() Function The IntlCalendar::fromDateTime() function is an inbuilt function in PHP which is used to create an IntlCalendar from a DateTime object or string. The value of new calendar represents the same instant as the DateTime and timezone. Syntax: Object oriented style IntlCalendar IntlCalendar::fromDateTime( 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 equals() Function 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 ) Proced 2 min read 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 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 Like