{site_name}

{site_name}

🌜 搜索

The IntlCalendar class in PHP is part of

php 𝄐 0
php include,phpinfo,phpinfo函数的作用,ph平均值计算公式,ph平均值如何计算,ph品牌
The IntlCalendar class in PHP is part of the PHP Internationalization extension (Intl) and provides a set of functions for working with calendars and dates. It is a wrapper around ICU (International Components for Unicode) library's calendar functionality.

Here is an example to demonstrate how to use the IntlCalendar class:

php
<?php
$calendar = IntlCalendar::createInstance();
$calendar->set(2022, 0, 1); // Set the calendar date to January 1, 2022
$calendar->add(IntlCalendar::FIELD_DAY_OF_MONTH, 2); // Add 2 days

$dateFormatter = IntlDateFormatter::create(
locale_get_default(),
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
$calendar->getTimeZone()
);
echo $dateFormatter->format($calendar->getTime());

// Output: Saturday, January 3, 2022 at 12:00:00 AM GMT
?>


In this example, we create an instance of IntlCalendar and set the date to January 1, 2022. Then, we add 2 days to the calendar using the add() method. Finally, we use the IntlDateFormatter class to format and output the modified date.

Please note that the above example is just a basic demonstration of using the IntlCalendar class. There are many more methods and options available for working with calendars and dates using this class. You can refer to the PHP documentation for more detailed information and examples.