- Object Oriented Style:
int IntlDateFormatter::getCalendar (void )
- Procedural style:
int datefmt_get_calendar (IntlDateFormatter $fmt)
// Create date formatter
$formatter
= datefmt_create (
’en_US’
,
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
’ Asia / Kolkata’
,
IntlDateFormatter::TRADITIONAL,
" MM / dd / yyyy "
);
// Get the calendar type
echo
’Calendar of formatter:’
. datefmt_get_calendar (
$formatter
).
""
;
// Get the date / time value formatted as a string
echo
"Formatted calendar output:"
. datefmt_format (
$formatter
, 0).
""
;
// Set the type of calendar used by the formatter
datefmt_set_calendar (
$formatter
,
IntlDateFormatter::GREGORIAN);
// Get the calendar type
echo
’Calendar of formatter:’
. datefmt_get_calendar (
$formatter
).
""
;
// Get the date / time value formatted as a string
echo
"First Formatted output is"
. datefmt_format (
$formatter
, 0);
?>
Exit:Calendar of formatter : 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 1 First Formatted output is 01/01/1970
Program 2:
// Create a date formatter
$formatter
= datefmt_create (
’en_US’
,
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
’Asia / Kolkata’
,
IntlDateFormatter::TRADITIONAL,
"MM / dd / yyyy"
);
// Get the calendar type
echo
’Calendar of formatter:’
.
$formatter
-> getCalendar().
""
;
// Get the date / time value formatted as a string
echo
"Formatted calendar output:"
.
$formatter
-> format (0).
""
;
// Set the type of calendar used by the formatter
$formatter
-> setCalendar (IntlDateFormatter::GREGORIAN);
// Get the calendar type
echo
’Calendar of formatter:’
.
$formatter
-> getCalendar().
""
;
// Get the date / time value formatted as a string
echo
"First Formatted output is"
.
$formatter
-> format (0);
?>
Exit:Calendar of formatter : 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 1 First Formatted output is 01/01/1970
Link: https://www.php.net/manual/en/intldateformatter.getcalendar.php