IntlCalendar::get()函数是PHP中的内置函数,用于获取特定字段的值。
用法:
- 面向对象的风格
int IntlCalendar::get( int $field )
- 程序风格
int intlcal_get( IntlCalendar $cal, int $field )
参数:此函数使用上面提到和下面描述的两个参数:
- $cal:此参数保存IntlCalendar的资源。
- $field:此参数保存IntlCalendar日期/时间字段常量之一。该字段包含一个介于0到IntlCalendar::FIELD_COUNT之间的整数值。
返回值:该函数返回保存时间字段值的整数。
以下示例程序旨在说明PHP中的IntlCalendar::get()函数:
程序:
<?php
// Set the DateTime zone
ini_set('date.timezone', 'Asia/Calcutta');
// Declare the IntlCalendar class
$cls = new ReflectionClass('IntlCalendar');
// Declare an empty array
$arr = array();
// Loop for IntlCalendar constants
foreach ($cls->getConstants() as $constName => $constVal) {
$arr[$constVal] = $constName;
}
// Create an instance of IntlCalendar
$calendar = IntlCalendar::createInstance();
// Display the date object
var_dump(IntlDateFormatter::formatObject($calendar));
// Loop to display result
foreach ($arr as $constVal => $constName) {
echo "Constant Name: " . $constName .
"\nConstant Value: " . $calendar->get($constVal) . "\n\n";
}
?>
输出:
string(25) "Sep 23, 2019, 11:03:29 AM" Constant Name: WALLTIME_LAST Constant Value: 1 Constant Name: WALLTIME_FIRST Constant Value: 2019 Constant Name: WALLTIME_NEXT_VALID Constant Value: 8 Constant Name: DOW_TYPE_WEEKEND_CEASE Constant Value: 39 Constant Name: DOW_WEDNESDAY Constant Value: 4 Constant Name: DOW_THURSDAY Constant Value: 23 Constant Name: DOW_FRIDAY Constant Value: 266 Constant Name: DOW_SATURDAY Constant Value: 2 Constant Name: FIELD_DAY_OF_WEEK_IN_MONTH Constant Value: 4 Constant Name: FIELD_AM_PM Constant Value: 0 Constant Name: FIELD_HOUR Constant Value: 11 Constant Name: FIELD_HOUR_OF_DAY Constant Value: 11 Constant Name: FIELD_MINUTE Constant Value: 3 Constant Name: FIELD_SECOND Constant Value: 29 Constant Name: FIELD_MILLISECOND Constant Value: 939 Constant Name: FIELD_ZONE_OFFSET Constant Value: 19800000 Constant Name: FIELD_DST_OFFSET Constant Value: 0 Constant Name: FIELD_YEAR_WOY Constant Value: 2019 Constant Name: FIELD_DOW_LOCAL Constant Value: 2 Constant Name: FIELD_EXTENDED_YEAR Constant Value: 2019 Constant Name: FIELD_JULIAN_DAY Constant Value: 2458750 Constant Name: FIELD_MILLISECONDS_IN_DAY Constant Value: 39809939 Constant Name: FIELD_IS_LEAP_MONTH Constant Value: 0 Constant Name: FIELD_FIELD_COUNT Constant Value:
参考: https://www.php.net/manual/en/intlcalendar.get.php
相关用法
- PHP IntlCalendar add()用法及代码示例
- PHP IntlCalendar after()用法及代码示例
- PHP IntlCalendar before()用法及代码示例
- PHP IntlCalendar set()用法及代码示例
- PHP IntlCalendar roll()用法及代码示例
- PHP IntlCalendar isWeekend()用法及代码示例
- PHP IntlCalendar setTimeZone()用法及代码示例
- PHP IntlCalendar getAvailableLocales()用法及代码示例
- PHP IntlCalendar isSet()用法及代码示例
- PHP IntlCalendar inDaylightTime()用法及代码示例
- PHP IntlCalendar getTimeZone()用法及代码示例
- PHP IntlCalendar getLeastMaximum()用法及代码示例
- PHP IntlCalendar setTime()用法及代码示例
- PHP IntlCalendar isEquivalentTo()用法及代码示例
- PHP IntlCalendar toDateTime()用法及代码示例
注:本文由纯净天空筛选整理自jit_t大神的英文原创作品 PHP | IntlCalendar get() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。