Home > Article > Backend Development > What does date_create mean in php
PHP date_create() function
Definition and usage
date_create() function returns new A DateTime object.
Grammar (recommended learning: PHP video tutorial)
date_create(time,timezone);<br/>
time: Optional. Specifies a date/time string. NULL indicates the current date/time.
timezone: Optional. Specifies the time zone for time. The default is the current time zone.
Example
Returns a new DateTime object, then formats the date:
<!DOCTYPE html><br/><html><br/><body><br/><br/><?php<br/>$date=date_create("2016-09-25");<br/>echo date_format($date,"Y/m/d");<br/>?><br/><br/></body><br/></html><br/>
Returns a new DateTime object with the given time zone , and then format that date and time:
<!DOCTYPE html><br/><html><br/><body><br/><br/><?php<br/>$date=date_create("2013-03-15 23:40:00",timezone_open("Europe/Oslo"));<br/>echo date_format($date,"Y/m/d H:iP");<br/>?><br/><br/></body><br/></html><br/>
The above is the detailed content of What does date_create mean in php. For more information, please follow other related articles on the PHP Chinese website!