La función IntlCalendar::get() es una función incorporada en PHP que se utiliza para obtener el valor de un campo específico.
Sintaxis:
- Estilo orientado a objetos
int IntlCalendar::get( int $field )
- Estilo procesal
int intlcal_get( IntlCalendar $cal, int $field )
Parámetros: esta función utiliza dos parámetros, como se mencionó anteriormente y se describe a continuación:
- $cal: este parámetro contiene el recurso de IntlCalendar.
- $field: este parámetro contiene una de las constantes de campo de fecha/hora de IntlCalendar. Este campo contiene un valor entero que se encuentra entre 0 e IntlCalendar::FIELD_COUNT.
Valor de retorno: esta función devuelve el número entero que contiene el valor del campo de tiempo.
El siguiente programa ilustra la función IntlCalendar::get() en PHP:
Programa:
<?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"; } ?>
Producció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:
Referencia: https://www.php.net/manual/en/intlcalendar.get.php