Home >Backend Development >PHP Problem >What does date_create mean in php

What does date_create mean in php

(*-*)浩
(*-*)浩Original
2019-09-05 11:11:403789browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn