Change language

PHP IntlCalendar createInstance () function

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 contains the time zone to use.
    • NULL:this is the default time zone.
    • IntlTimeZone:is used directly.
    • DateTimeZone:allows you to set the timzone in DateTimeZone format. The DateTimeZone ID will be retrieved and an ICU time zone object will be created.
    • string:This is a valid ICU time zone ID.
  • $locale:this parameter contains the locale to use, or NULL to use the default locale.
Return Value:This function generates an instance of IntlCalendar on success, or NULL on failure.The following programs illustrate the IntlCalendar::createInstance() function in PHP:Program 1:  
// 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’ );  
// Using the IntlCalendar::before() function var_dump ( $calendar1 -> before ( $calendar2 )); var_dump ( $calendar2 -> before ( $calendar1 ));  
// Using the IntlCalendar::before() function var_dump ( $calendar1 -> after ( $calendar2 )); var_dump ( $calendar2 -> after ( $calendar1 ));  
?>
Exit:
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 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 ));  
?>
Exit:
bool (true )
Link: https://www.php.net /manual/en/intlcalendar.createinstance.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method