Easy Tutorial
❮ Php Ref Math Func Mysqli Get Client Version ❯

PHP date_create() Function

PHP Date/Time Reference Manual

Example

Returns a new DateTime object and then formats the date:


Definition and Usage

The date_create() function returns a new DateTime object.

Syntax

Parameter Description
time Optional. Specifies a date/time string. NULL indicates the current date/time.
timezone Optional. Specifies the timezone of time. The default is the current timezone. <br> <br> Tip: View a list of all timezones supported in PHP

Technical Details

Return Value: Returns a new DateTime object if successful, FALSE otherwise.
PHP Version: 5.2+
--- ---
Changelog: Starting from PHP 5.3+, an exception is thrown if an invalid date is specified.
--- ---

More Examples

Example 1

Returns a new DateTime object with a specified timezone, then formats the date and time:


❮ Php Ref Math Func Mysqli Get Client Version ❯