IntlCalendar::createInstance
(PHP 5.5.0, PHP 7, PECL >= 3.0.0a1)
IntlCalendar::createInstance — Create a new IntlCalendar
Описание
Объектно-ориентированный стиль
$timeZone
= NULL
[, string $locale
= ""
]] )Процедурный стиль
Given a timezone and locale, this method creates an IntlCalendar object. This factory method may return a subclass of IntlCalendar.
The calendar created will represent the time instance at which it was created, based on the system time. The fields can all be cleared by calling IntCalendar::clear() with no arguments. See also IntlGregorianCalendar::__construct().
Список параметров
-
timeZone
-
The timezone to use.
-
NULL
, in which case the default timezone will be used, as specified in the ini setting date.timezone or through the function date_default_timezone_set() and as returned by date_default_timezone_get(). -
An IntlTimeZone, which will be used directly.
-
A DateTimeZone. Its identifier will be extracted and an ICU timezone object will be created; the timezone will be backed by ICUʼs database, not PHPʼs.
-
A string, which should be a valid ICU timezone identifier. See IntlTimeZone::createTimeZoneIDEnumeration(). Raw offsets such as "GMT+08:30" are also accepted.
-
-
locale
-
A locale to use or
NULL
to use the default locale.
Возвращаемые значения
The created IntlCalendar instance or NULL
on
failure.
Примеры
Пример #1 IntlCalendar::createInstance()
<?php
ini_set('intl.default_locale', 'es_ES');
ini_set('date.timezone', 'Europe/Madrid');
$cal = IntlCalendar::createInstance();
echo "No arguments\n";
var_dump(get_class($cal),
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL));
echo "\n";
echo "Explicit timezone\n";
$cal = IntlCalendar::createInstance(IntlTimeZone::getGMT());
var_dump(get_class($cal),
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL));
echo "\n";
echo "Explicit locale (with calendar)\n";
$cal = IntlCalendar::createInstance(NULL, 'es_ES@calendar=persian');
var_dump(get_class($cal),
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL));
Результат выполнения данного примера:
No arguments string(21) "IntlGregorianCalendar" string(68) "martes 18 de junio de 2013 14:11:02 Hora de verano de Europa Central" Explicit timezone string(21) "IntlGregorianCalendar" string(45) "martes 18 de junio de 2013 12:11:02 GMT+00:00" Explicit locale (with calendar) string(12) "IntlCalendar" string(70) "martes 28 de Khordad de 1392 14:11:02 Hora de verano de Europa Central"
Смотрите также
- IntlGregorianCalendar::__construct()
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Поддержка языков и кодировок
- Internationalization Functions
- Функция IntlCalendar::add() - Add a (signed) amount of time to a field
- Функция IntlCalendar::after() - Whether this objectʼs time is after that of the passed object
- Функция IntlCalendar::before() - Whether this objectʼs time is before that of the passed object
- Функция IntlCalendar::clear() - Clear a field or all fields
- Функция IntlCalendar::__construct() - Private constructor for disallowing instantiation
- Функция IntlCalendar::createInstance() - Create a new IntlCalendar
- Функция IntlCalendar::equals() - Compare time of two IntlCalendar objects for equality
- Функция IntlCalendar::fieldDifference() - Calculate difference between given time and this objectʼs time
- Функция IntlCalendar::fromDateTime() - Create an IntlCalendar from a DateTime object or string
- Функция IntlCalendar::get() - Get the value for a field
- Функция IntlCalendar::getActualMaximum() - The maximum value for a field, considering the objectʼs current time
- Функция IntlCalendar::getActualMinimum() - The minimum value for a field, considering the objectʼs current time
- Функция IntlCalendar::getAvailableLocales() - Get array of locales for which there is data
- Функция IntlCalendar::getDayOfWeekType() - Tell whether a day is a weekday, weekend or a day that has a transition between the two
- Функция IntlCalendar::getErrorCode() - Get last error code on the object
- Функция IntlCalendar::getErrorMessage() - Get last error message on the object
- Функция IntlCalendar::getFirstDayOfWeek() - Get the first day of the week for the calendarʼs locale
- Функция IntlCalendar::getGreatestMinimum() - Get the largest local minimum value for a field
- Функция IntlCalendar::getKeywordValuesForLocale() - Get set of locale keyword values
- Функция IntlCalendar::getLeastMaximum() - Get the smallest local maximum for a field
- Функция IntlCalendar::getLocale() - Get the locale associated with the object
- Функция IntlCalendar::getMaximum() - Get the global maximum value for a field
- Функция IntlCalendar::getMinimalDaysInFirstWeek() - Get minimal number of days the first week in a year or month can have
- Функция IntlCalendar::getMinimum() - Get the global minimum value for a field
- Функция IntlCalendar::getNow() - Get number representing the current time
- Функция IntlCalendar::getRepeatedWallTimeOption() - Get behavior for handling repeating wall time
- Функция IntlCalendar::getSkippedWallTimeOption() - Get behavior for handling skipped wall time
- Функция IntlCalendar::getTime() - Get time currently represented by the object
- Функция IntlCalendar::getTimeZone() - Get the objectʼs timezone
- Функция IntlCalendar::getType() - Get the calendar type
- Функция IntlCalendar::getWeekendTransition() - Get time of the day at which weekend begins or ends
- Функция IntlCalendar::inDaylightTime() - Whether the objectʼs time is in Daylight Savings Time
- Функция IntlCalendar::isEquivalentTo() - Whether another calendar is equal but for a different time
- Функция IntlCalendar::isLenient() - Whether date/time interpretation is in lenient mode
- Функция IntlCalendar::isSet() - Whether a field is set
- Функция IntlCalendar::isWeekend() - Whether a certain date/time is in the weekend
- Функция IntlCalendar::roll() - Add value to field without carrying into more significant fields
- Функция IntlCalendar::set() - Set a time field or several common fields at once
- Функция IntlCalendar::setFirstDayOfWeek() - Set the day on which the week is deemed to start
- Функция IntlCalendar::setLenient() - Set whether date/time interpretation is to be lenient
- Функция IntlCalendar::setMinimalDaysInFirstWeek() - Set minimal number of days the first week in a year or month can have
- Функция IntlCalendar::setRepeatedWallTimeOption() - Set behavior for handling repeating wall times at negative timezone offset transitions
- Функция IntlCalendar::setSkippedWallTimeOption() - Set behavior for handling skipped wall times at positive timezone offset transitions
- Функция IntlCalendar::setTime() - Set the calendar time in milliseconds since the epoch
- Функция IntlCalendar::setTimeZone() - Set the timezone used by this calendar
- Функция IntlCalendar::toDateTime() - Convert an IntlCalendar into a DateTime object
Коментарии
404 Not Found