PHP | IntlDateFormatter formatObject() Function Last Updated : 24 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The IntlDateFormatter::formatObject() function is an inbuilt function in PHP which is used to formats an IntlDateFormatter object. This function allows to format the IntlCalendar or DateTime object. Syntax: Object oriented style:string IntlDateFormatter::formatObject( object $object, mixed $format = NULL, string $locale = NULL )Procedural style:string datefmt_format_object( object $object, mixed $format = NULL, string $locale = NULL ) Parameters: This function accepts three parameters as mentioned above and described below: object: This parameter holds the object of IntlCalendar or DateTime type.format: This parameter holds the format of date to set the date in given format. It can be used array with two values (first set the date style and second set the time style. The constants are IntlDateFormatter::NONE, IntlDateFormatter::SHORT, IntlDateFormatter::MEDIUM, IntlDateFormatter::LONG, IntlDateFormatter::FULL), integer or string format. The NULL value is used for default style.locale: This parameter holds the used locale. The NULL value is used for default locale. Return Value: This function returns a string in given format on success or False on failure. Below program illustrates the IntlDateFormatter::formatObject() function in PHP: Program: php <?php // Set the timezone and locale ini_set('date.timezone', 'Asia/Calcutta'); ini_set('intl.default_locale', 'en_US'); // Create an IntlCalendar from a DateTime object or string $calendar = IntlCalendar::fromDateTime('2019-10-05 09:19:29'); // Display the date in given format echo "Default date format => " . IntlDateFormatter::formatObject($calendar) . "\n"; // Display the date in given format echo "Date in string format => " . IntlDateFormatter::formatObject($calendar, "dd MM yyyy") . "\n"; // Display the date in given format echo "Date in long format => " . IntlDateFormatter::formatObject($calendar, IntlDateFormatter::TRADITIONAL) . "\n"; // Display the date in given format echo "Date in array format => ", IntlDateFormatter::formatObject($calendar, array( IntlDateFormatter::NONE, IntlDateFormatter::FULL) ); ?> Output:Default date format => Oct 5, 2019, 9:19:29 AM Date in string format => 05 10 2019 Date in long format => Saturday, October 5, 2019 at 9:19:29 AM India Standard Time Date in array format => 9:19:29 AM India Standard Time Reference: https://www.php.net/manual/en/intldateformatter.formatobject.php Comment More infoAdvertise with us Next Article PHP | IntlDateFormatter formatObject() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Intl Similar Reads PHP | IntlDateFormatter format() Function The IntlDateFormatter::format() function is an inbuilt function in PHP which is used to format the date/time value as a string. Syntax: Object oriented style: string IntlDateFormatter::format( mixed $value ) Procedural style: string datefmt_format( IntlDateFormatter $fmt, mixed $value ) Parameters: 2 min read PHP | IntlCalendar fromDateTime() Function The IntlCalendar::fromDateTime() function is an inbuilt function in PHP which is used to create an IntlCalendar from a DateTime object or string. The value of new calendar represents the same instant as the DateTime and timezone. Syntax: Object oriented style IntlCalendar IntlCalendar::fromDateTime( 2 min read PHP | IntlDateFormatter getDateType() Function 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 ) Paramete 2 min read PHP | IntlDateFormatter getCalendar() Function The IntlDateFormatter::getCalendar() function is an inbuilt function in PHP which is used to return the calendar type used for the IntlDateFormatter object.Syntax: Object oriented style: int IntlDateFormatter::getCalendar( void )Procedural style: int datefmt_get_calendar( IntlDateFormatter $fmt ) Pa 2 min read PHP | IntlDateFormatter getErrorCode() Function, The IntlDateFormatter::getErrorCode() function is an inbuilt function in PHP which is used to return the error code from last operation. Syntax: Object-oriented style: int IntlDateFormatter::getErrorCode( void ) Procedural style: int datefmt_get_error_code( IntlDateFormatter $fmt ) Parameters: This 1 min read Like