PHP | IntlCalendar createInstance() Function Improve Improve Like Article Like Save Share 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 // 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 // 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 Last Updated : 28 Mar, 2022 Like Article Save Article Previous PHP | IntlChar getFC_NFKC_Closure() Function Next PHP | simplexml_load_file() Function Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads PHP | IntlCalendar isWeekend() Function PHP | IntlCalendar roll() Function PHP | IntlCalendar set() Function PHP | IntlCalendar add() Function PHP | IntlCalendar after() Function PHP | IntlCalendar before() Function PHP | IntlCalendar::__construct() Function PHP | IntlCalendar equals() Function PHP | IntlCalendar fieldDifference() Function PHP | IntlCalendar getActualMaximum() Function Like jit_t Follow Article Tags : PHP-function PHP-Intl PHP Web Technologies