What does date_create mean in php

(*-*)浩
Release: 2023-02-23 16:42:02
Original
3749 people have browsed it

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/>
Copy after login

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/>
Copy after login

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/>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template