- Object Oriented Style:
int IntlDateFormatter::getDateType (void )
- Procedural style:
int datefmt_get_datetype (IntlDateFormatter $fmt)
// Create date formatter
$formatter
= datefmt_create (
’ en_US’
,
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
’Asia / Kolkata’
,
IntlDateFormatter::TRADITIONAL,
"MM / dd / yyyy"
);
// Get the type of date / type formatter
echo
’Calendar of formatter:’
. datefmt_get_datetype (
$formatter
).
""
;
// Get the date / time value formatted as a string
echo
"Formatted calendar output:"
. datefmt_format (
$formatter
, 0).
""
;
// Create a date formatter
$formatter
= datefmt_create (
’en_US’
,
IntlDateFormatter::SHORT,
IntlDateFormatter::SHORT,
’Asia / Kolkata’
,
IntlDateFormatter::TRADITIONAL
);
// Get the type of date / type formatter
echo
’Calendar of formatter:’
. datefmt_get_datetype (
$formatter
).
""
;
// Get the date / time value formatted as a string
echo
"Formatted calendar output:"
. datefmt_format (
$formatter
, 0);
?>
Exit:Calendar of formatter : 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 3 Formatted calendar output: 1/1/70, 5:30 AM
Program 2:
// Create date formatter
$formatter
= datefmt_create (
’en_US’
,
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
’Asia / Kolkata’
,
IntlDateFormatter::TRADITIONAL,
"MM / dd / yyyy"
);
// Get the type of date / type formatter
echo
’Calendar of formatter:’
.
$formatter
-> getDateType().
""
;
// Get date / time format
// string value
echo
"Formatted calendar output: "
.
$formatter
-> format (0).
""
;
// Create a date formatter
$formatter
= datefmt_create (
’en_US’
,
IntlDateFormatter::SHORT,
IntlDateFormatter::SHORT,
’Asia / Kolkata’
,
IntlDateFormatter::TRADITIONAL
);
// Get the type of date / type formatter
echo
’Calendar of formatter:’
.
$formatter
-> getDateType().
""
;
// Get date / time format
// string value
echo
"Formatted calendar output: "
.
$formatter
-> format (0);
?>
Exit:Calendar of formatter : 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 3 Formatted calendar output: 1/1/70, 5:30 AM
Link:https://www.php.net/manual/en/intldateformatter.getdatetype.php