The IntlDateFormatter::getDateType() function is an inbuilt function in PHP which is used to get the datetype used for the IntlDateFormatter object.
Syntax:
- Object oriented style:
int IntlDateFormatter::getDateType( void )
- Procedural style:
int datefmt_get_datetype( IntlDateFormatter $fmt )
Parameters: This function uses single parameter $fmt which holds the resource of formatter.
Return Value: This function returns the current date type value of the formatter.
Below programs illustrate the IntlDateFormatter::getDateType() function in PHP:
Program 1:
<?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); ?> |
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:
<?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); ?> |
Calendar of formatter: 0 Formatted calendar output: 01/01/1970 Calendar of formatter: 3 Formatted calendar output: 1/1/70, 5:30 AM
Reference: https://www.php.net/manual/en/intldateformatter.getdatetype.php