PHP | date_create_immutable_from_format() Function Last Updated : 06 Aug, 2021 Comments Improve Suggest changes Like Article Like Report The date_create_immutable_from_format() function is an inbuilt function in PHP which is used to parse a time string according to the specified format. Syntax: Object oriented style: DateTimeImmutable static DateTime::createFromFormat( string $format, string $time, DateTimeZone $timezone )Procedural style: DateTimeImmutable date_create_from_format( string $format, string $time, DateTimeZone $timezone ) Parameters: This function uses three parameters as mentioned above and described below: $format: This parameter holds the DateTime format in string.$time: This parameter holds the time in string format.$timezone: This parameter holds the DateTimeZone object. Return Value: This function returns a new DateTimeImmutable object representing the date and time specified by the time string, which was formatted in the given format. Characters and its description: Format characterDescriptionExample returned valuesjDay of the month without leading zeros1 to 31dDay of the month with leading zeros01 to 31mNumeric representation of the month01 to 12MShort textual representation of the monthJan to DecYRepresentation of a year1989, 2017 The format string can be a combination of any of the format characters in any order but we would have to provide the input date-time string in the same order. Below programs illustrate the date_create_immutable_from_format() function in PHP: Program 1: PHP <?php // Use date_create_from_format() function // to create a date format $date = date_create_from_format('j-M-Y', '03-oct-2019'); // Display the date echo date_format($date, 'Y-m-d'); ?> Output: 2019-10-03 Program 2: PHP <?php // Use date_create_from_format() function // to create a date format $date = date_create_from_format('d-M-Y', '03-oct-2019'); // Display the date echo date_format($date, 'Y-m-j'); ?> Output: 2019-10-3 Program 3: PHP <?php // Use DateTime::createFromFormat() function // to create a date object $date = DateTime::createFromFormat('j-M-Y', '03-oct-2019'); // Display the date echo $date->format('Y-m-d'); ?> Output: 2019-10-03 Reference: https://www.php.net/manual/en/datetimeimmutable.createfromformat.php Comment More infoAdvertise with us Next Article PHP | date_create_immutable_from_format() Function S SomeshwarRoychowdhury1 Follow Improve Article Tags : Technical Scripter Web Technologies PHP Technical Scripter 2019 PHP-date-time PHP-function +2 More Similar Reads PHP | date_create_from_format() Function The date_create_from_format() is an inbuilt function in php which is used to parses a time string according to a specified format. This function accepts three parameters and returns new DateTime in success or false on failure. Syntax: Procedural style date_create_from_format ( $format, $time, $timez 3 min read PHP | date_parse_from_format() Function The date_parse_from_format() is an inbuilt function in PHP which is used to get information about given date formatted according to the specified format. The date_parse_from_format() function accepts two parameters and returns associative array with detailed information about given date. Syntax: arr 3 min read PHP | DateTime format() Function The DateTime::format() function is an inbuilt function in PHP which is used to return the new formatted date according to the specified format. Syntax: Object oriented style string DateTime::format( string $format ) or string DateTimeImmutable::format( string $format ) or string DateTimeInterface::f 1 min read PHP | date_create(), date_format(), date_add() Functions There is some point in time when we need to add a number of days, months, years, hours, minutes and seconds to Date and time. PHP serves us with several built-in functions to do this. Some built-in functions that we will discuss here are date_create(), date_format() and date_add(). date_create() Fun 3 min read PHP | DateTime createFromFormat() Function The DateTime::createFromFormat()function is an inbuilt function in PHP which returns a new DateTime object representing the date and time format. Syntax: Object oriented style: DateTime DateTime::createFromFormat( string $format, string $time, DateTimeZone $timezone ) Procedural style: DateTime date 3 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 | date_get_last_errors() Function The date_get_last_errors() function is an inbuilt function in PHP which is used to returns the warnings and errors. This function parse a date/time string and returns an array of warnings and errors. Syntax: Procedural style: array date_get_last_errors( void ) Object oriented style: array DateTime:: 1 min read PHP | easter_date() Function The easter_date() function is a built-in function in PHP which returns the Easter date in the year passed as an argument. The current year is taken as default year when no arguments are passed as parameter. Syntax: easter_date( $year ) Parameter: The function accepts one optional parameter $year whi 2 min read PHP | cal_from_jd() Function The cal_from_jd() function is an inbuilt function in PHP that is used to convert a Julian Day Count into a supported calendar such as the Gregorian calendar, French Calendar, Jewish calendar, etc. This function accepts two parameters $jd and $calendar and returns the array containing calendar inform 2 min read PHP date() format when inserting into datetime in MySQL This problem describes the date format for inserting the date into MySQL database. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The date can be stored in this format only. However, it can be used with any time format functions to change it and display it. When writin 3 min read Like