- Object Oriented Style:
IntlCalendar IntlCalendar::createInstance (mixed $timeZone = NULL, string $locale = "")
- Procedural style:
IntlCalendar intlcal_create_instance (mixed $timeZone = NULL, string $locale = "")
- $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.
// 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