Easy Tutorial
❮ Func Date Date Format Php Mysql Insert Multiple ❯

PHP strptime() Function

PHP Date/Time Reference Manual

Example

Parsing a time/date generated by strftime():


Definition and Usage

The strptime() function parses a time/date generated by strftime().

Note: This function is not implemented on Windows platforms!

Syntax

Parameter Description
date Required. The string to be parsed (e.g., returned by strftime()).
format Required. Specifies the format to be used for the date: %a - Abbreviated weekday name<br> %A - Full weekday name<br> %b - Abbreviated month name<br> %B - Full month name<br> %c - Preferred date and time representation<br> %C - Century number (the year divided by 100, range 00 to 99)<br> %d - Day of the month (01 to 31)<br> %D - Time format, same as %m/%d/%y<br> %e - Day of the month (1 to 31)<br> %g - Similar to %G, but without the century<br> %G - 4-digit year corresponding to the ISO week number (see %V)<br> %h - Same as %b<br> %H - Hour, using a 24-hour format (00 to 23)<br> %I - Hour, using a 12-hour format (01 to 12)<br> %j - Day of the year (001 to 366)<br> %m - Month (01 to 12)<br> %M - Minutes<br> %n - Newline character<br> %p - Either am or pm according to the given time value<br> %r - Time in a.m. and p.m. notation<br> %R - Time in 24-hour notation<br> %S - Seconds<br> %t - Tab character<br> %T - Current time, same as %H:%M:%S<br> %u - Day of the week as a number (1 to 7), Monday = 1. Warning: In Sun Solaris Sunday = 1<br> %U - Week number of the current year, starting with the first Sunday as the first day of the first week<br> %V - ISO 8601 week number of the current year (01 to 53), where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week<br> %W - Week number of the current year, starting with the first Monday as the first day of the first week<br> %w - Day of the week as a decimal, Sunday = 0<br> %x - Preferred date representation without the time<br> %X - Preferred time representation without the date<br> %y - Year without a century (range 00 to 99)<br> %Y - Year including the century<br> %Z or %z - Time zone name or abbreviation<br> %% - A % character

Technical Details

Return Value: Returns an array on success with parsed date information. FALSE on failure. The keys of the returned array are as follows: [tm_sec] - Seconds within the minute (0-61)<br> [tm_min] - Minutes within the hour (0-59)<br> [tm_hour] - Hour since midnight (0-23)<br> [tm_mday] - Day of the month (1-31)<br> [tm_mon] - Months since January (0-11)<br> [tm_year] - Years since 1900<br> [tm_wday] - Days since Sunday (0-6)<br> [tm_yday] - Days since January 1 (0-365)<br> [unparsed] - The date part which was not recognized using the specified format
PHP Version: 5.1+
--- ---
❮ Func Date Date Format Php Mysql Insert Multiple ❯