Definition :
PHP date_create_from_format() Function is inbuilt function in php.This function accepts a time string and format string as parameters, parses the given time string in the specified format and returns the result as a DateTime object.
date_create_from_format(format, time, timezone)
Parameter | Description |
---|---|
format | Required. Specifies the format to use. The following characters can be used in the format parameter string:
|
time | Required. Specifies a date/time string. NULL indicates the current date/time |
timezone | Optional. Specifies the timezone of time. Default is the current timezone |
GIven below example return a new DateTime object formatted according to the specified format :
Output : 2017/07/20