PHP date_create_from_format() Function

## PHP Basic

PHP HOME PHP Intro PHP Install PHP Syntax PHP Variables PHP Echo / Print PHP Data Types PHP String Functions PHP Constants PHP Operators PHP If...Else...Elseif PHP Switch PHP While Loops PHP For Loops PHP Functions PHP Arrays PHP Sorting Arrays PHP Superglobals

## PHP Forms

PHP Form Handling PHP Form Validation PHP Form Required PHP Form URL/E-mail PHP Form Complete

## PHP Advanced

PHP Arrays Multi PHP Date PHP Include PHP File PHP File Upload PHP Cookies PHP Sessions PHP E-mail PHP Secure E-mail PHP Error PHP Exception PHP Filter

## PHP Database

PHP MySQL Intro PHP MySQL Connect PHP CREATE DB/Table PHP INSERT INTO PHP SELECT PHP WHERE PHP ORDER BY PHP UPDATE PHP DELETE PHP ODBC

## PHP XML

XML Expat Parser XML DOM XML SimpleXML

## PHP and AJAX

AJAX Intro AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX RSS Reader AJAX Poll

## PHP Reference

PHP Array PHP Calendar PHP Date PHP Directory PHP Error PHP Filesystem PHP Filter PHP FTP PHP HTTP PHP Libxml PHP Mail PHP Math PHP Misc PHP MySQLi PHP SimpleXML PHP String PHP XML PHP Zip PHP Timezones

## PHP Quiz

PHP Quiz PHP Certificate

# PHP date_create_from_format() Function

PHP Date/Time Reference

## Example

Return a new DateTime object formatted according to the specified format:

<?php
$date=date_create_from_format("j-M-Y","15-Mar-2013");
?>
Run example »

## 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 | Description
--- | ---

format

Required. Specifies the format to use. The following characters can be used in the format parameter string:

- d - Day of the month; with leading zeros
- j - Day of the month; without leading zeros
- D - Day of the month (Mon - Sun)
- l - Day of the month (Monday - Sunday)
- S - English suffix for day of the month (st, nd, rd, th)
- F - Monthname (January - December)
- M - Monthname (Jan-Dec)
- m - Month (01-12)
- n - Month (1-12)
- Y - Year (e.g 2013)
- y - Year (e.g 13)
- a and A - am or pm
- g - 12 hour format with leading zeros
- h - 12 hour format without leading zeros
- G - 24 hour format with leading zeros
- H - 12 hour format without leading zeros
- i - Minutes with leading zeros
- s - Seconds with leading zeros
- u - Microseconds (up to six digits)
- e, O, P and T - Timezone identifier
- U - Seconds since Unix Epoch
- (space)
- # - One of the following separation symbol: ;,:,/,.,,,-,(,)
- ? - A random byte
- * - Rondom bytes until next separator/digit
- ! - Resets all fields to Unix Epoch
- | - Resets all fields to Unix Epoch if they have not been parsed yet
- + - If present, trailing data in the string will cause a warning, not an error

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

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE