HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

date_parse_from_format

Description

The date_parse_from_format of Date / Time for PHP get info about given date formatted according to the specified format.

Syntax

date_parse_from_format(
    string $format,
    string $datetime
): array

Parameters

format

The format that the passed in string should be in. See the formatting options below. In most cases, the same letters as for the date() can be used.

DayDescriptionExample
dDay of the month with leading zeros, 2 digits01 - 31
DShort textual representation of the day of the week, three lettersMon - Sun
jDay of the month without leading zeros1 - 31
l (lowercase L)Full textual representation of the day of the weekSunday - Saturday
NISO-8601 numeric representation of the day of the week1 - 7 (Monday - Sunday)
SEnglish ordinal suffix for the day of the month, 2 charactersst, nd, rd, th
wNumeric representation of the day of the week0 - 6 (Sunday - Saturday)
zDay of the year0 - 365
WeekDescriptionExample
WISO-8601 week of the year, weeks start on Monday1 - 52
MonthDescriptionExample
FFull textual representation of a monthJanuary - December
mNumeric representation of a month with leading zeros, 2 digits01 - 12
MShort textual representation of a month, three lettersJan - Dec
nNumeric representation of a month without leading zeros1 - 12
tNumber of days in the given month28 - 31
YearDescriptionExample
LWhether it's a leap year1 (leap year), 0 (otherwise)
oISO-8601 week-numbering year. The same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.Example: 1999
Y4 digit representation of a yearExample: 1999
y2 digit representation of a year00 - 99
TimeDescriptionExample
aLowercase Ante meridiem and Post meridiemam, pm
AUppercase Ante meridiem and Post meridiemAM, PM
BSwatch Internet time000 - 999
g12-hour format of an hour without leading zeros1 - 12
G24-hour format of an hour without leading zeros0 - 23
h12-hour format of an hour with leading zeros01 - 12
H24-hour format of an hour with leading zeros00 - 23
iMinutes with leading zeros00 - 59
sSeconds with leading zeros00 - 59
uMicroseconds. Note: date() will always generate 000000 since it takes an integer parameter, whereas DateTime::format() does support microseconds if DateTime was created with microseconds.Example: 654321
vMilliseconds. Same note as u.Example: 654
TimezoneDescriptionExample
eTimezone identifierExamples: UTC, GMT, Atlantic/Azores
I (uppercase i)Whether or not the date is in daylight saving time1 (daylight saving time), 0 (otherwise)
ODifference to Greenwich time (GMT) without colon between hours and minutesExample: +0200
PDifference to Greenwich time (GMT) with colon between hours and minutesExample: +02:00
TTimezone abbreviationExamples: EST, MDT ...
ZTimezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.-43200 - 50400
FullDescriptionExample
cISO 8601 dateExample: 2001-02-03T04:05:06+00:00
rRFC 2822 formatted dateExample: Sat, 03 Feb 2001 04:05:06 +0000
USeconds since the Unix Epoch (January 1 1970 00:00:00 GMT)See also time()

Unrecognized characters in the format string will be printed as-is. The Z format will always return 0 when using gmdate(). Note: Since this function only accepts integer timestamps the u format character is only useful when using the date_format() function with user based timestamps created with date_create().

datetime

String representing the date/time.

Return

Returns associative array with detailed info about given date/time.

Examples

1 · format datetime

<?

$format = "y m d h i s u P";
$datetime = "01 02 03 04 05 06 000007 +08:00";

$return = date_parse_from_format($format, $datetime);

print_r($return);
Array
(
    [year] => 2001
    [month] => 2
    [day] => 3
    [hour] => 4
    [minute] => 5
    [second] => 6
    [fraction] => 7.0E-6
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 0
    [errors] => Array
        (
        )

    [is_localtime] => 1
    [zone_type] => 1
    [zone] => 28800
    [is_dst] => 
)