PHP date_create_from_format() Function
Example
Return a new DateTime object formatted according to the specified format:
<?php
$date=date_create_from_format("j-M-Y","15-Mar-2013");
?>
Try it Yourself »
Definition and Usage
The date_create_from_format() function returns a new DateTime object formatted according to the specified format.
Syntax
date_create_from_format(format, time, timezone)
Parameter Values
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 |
Technical Details
Return Value: | Returns a new DateTime object on success. FALSE on failure |
---|---|
PHP Version: | 5.3+ |
❮ PHP Date/Time Reference