PHP date_parse_from_format() Function

In this chapter you will learn:

  1. Definition for PHP date_parse_from_format() Function
  2. Syntax for PHP date_parse_from_format() Function
  3. Parameter for PHP date_parse_from_format() Function
  4. Return for PHP date_parse_from_format() Function
  5. Example - Parse a date value

Definition

The date_parse_from_format() function parses a string and gets a date, according to the specified format.

Syntax

PHP date_parse_from_format() Function has the following syntax.

date_parse_from_format(format,date);

Parameter

ParameterIs RequiredDescription
formatRequired.Format accepted by date_create_from_format()
dateRequired.A data value in string

The following characters can be used in the format parameter string:

FormatDescription
dDay of the month; with leading zeros
jDay of the month; without leading zeros
DDay of the month (Mon - Sun)
IDay of the month (Monday - Sunday)
SEnglish suffix for day of the month (st, nd, rd, th)
FMonthname (January - December)
MMonthname (Jan-Dec)
mMonth (01-12)
nMonth (1-12)
YYear (e.g 2013)
yYear (e.g 13)
a and Aam or pm
g12 hour format with leading zeros
h12 hour format without leading zeros
G24 hour format with leading zeros
H12 hour format without leading zeros
iMinutes with leading zeros
sSeconds with leading zeros
uMicroseconds (up to six digits)
e, O, P and TTimezone identifier
USeconds since Unix Epoch
#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

Return

PHP date_parse_from_format() Function returns date data on success.

Example

Parse a date value


<?php
print_r(date_parse_from_format("mmddyyyy","05122013"));
?>

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. Definition for PHP date_sub() Function
  2. Syntax for PHP date_sub() Function
  3. Parameter for PHP date_sub() Function
  4. Return value from PHP date_sub() Function
  5. Example
Home » PHP Tutorial » PHP Date Functions
PHP checkdate() Function
PHP date() Function
PHP date_add() Function
PHP date_create() Function
PHP date_create_from_format() Function
PHP date_date_set() Function
PHP date_default_timezone_get() Function
PHP date_default_timezone_set() Function
PHP date_diff() Function
PHP date_format() Function
PHP date_get_last_errors() Function
PHP date_interval_format() Function
PHP date_isodate_set() Function
PHP date_modify() Function
PHP date_offset_get() Function
PHP date_parse() Function
PHP date_parse_from_format() Function
PHP date_sub() Function
PHP date_sun_info() Function
PHP date_sunrise() Function
PHP date_sunset() Function
PHP date_time_set() Function
PHP date_timestamp_get() Function
PHP date_timestamp_set() Function
PHP date_timezone_get() Function
PHP date_timezone_set() Function
PHP getdate() Function
PHP gettimeofday() Function
PHP gmdate() Function
PHP gmmktime() Function
PHP gmstrftime() Function
PHP idate() Function
PHP localtime() Function
PHP microtime() Function
PHP mktime() Function
PHP strftime() Function
PHP strptime() Function
PHP strtotime() Function
PHP time() Function
PHP Timezones Constant
PHP timezone_abbreviations_list() Function
PHP timezone_identifiers_list() Function
PHP timezone_location_get() Function
PHP timezone_name_from_abbr() Function
PHP timezone_name_get() Function
PHP timezone_offset_get() Function
PHP timezone_open() Function
PHP timezone_version_get() Function