The IntlDateFormatter::getDateType() function is an inbuilt function in PHP which is used to get the datetype used for the IntlDateFormatter object.
Syntax:
php
php
- Object oriented style:
int IntlDateFormatter::getDateType( void )
- Procedural style:
int datefmt_get_datetype( IntlDateFormatter $fmt )
<?php
// Create a date formatter
$formatter = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'Asia/Kolkata',
IntlDateFormatter::TRADITIONAL,
"MM/dd/yyyy"
);
// Get the date/type formatter type
echo 'Calendar of formatter: '
. datefmt_get_datetype($formatter) . "\n";
// Get the format of date/time value as a string
echo "Formatted calendar output: "
. datefmt_format( $formatter , 0) . "\n\n";
// Create a date formatter
$formatter = datefmt_create(
'en_US',
IntlDateFormatter::SHORT,
IntlDateFormatter::SHORT,
'Asia/Kolkata',
IntlDateFormatter::TRADITIONAL
);
// Get the date/type formatter type
echo 'Calendar of formatter: '
. datefmt_get_datetype($formatter) . "\n";
// Get the format of date/time value as a string
echo "Formatted calendar output: "
. datefmt_format( $formatter , 0);
?>
Output:
Program 2:
Calendar of formatter: 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 3 Formatted calendar output: 1/1/70, 5:30 AM
<?php
// Create a date formatter
$formatter = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'Asia/Kolkata',
IntlDateFormatter::TRADITIONAL,
"MM/dd/yyyy"
);
// Get the date/type formatter type
echo 'Calendar of formatter: '
. $formatter->getDateType() . "\n";
// Get the format of date/time
// value as a string
echo "Formatted calendar output: "
. $formatter->format(0) . "\n\n";
// Create a date formatter
$formatter = datefmt_create(
'en_US',
IntlDateFormatter::SHORT,
IntlDateFormatter::SHORT,
'Asia/Kolkata',
IntlDateFormatter::TRADITIONAL
);
// Get the date/type formatter type
echo 'Calendar of formatter: '
. $formatter->getDateType() . "\n";
// Get the format of date/time
// value as a string
echo "Formatted calendar output: "
. $formatter->format(0);
?>
Output:
Reference: https://www.php.net/manual/en/intldateformatter.getdatetype.phpCalendar of formatter: 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 3 Formatted calendar output: 1/1/70, 5:30 AM