Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP strptime() Function

PHP strptime() Function

PHP Date/Time PHP Date/Time Reference Manual

Example

Parse 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

strptime(

date,format);

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

    Technical Details

    | Return Value: | Returns an array with the parsed date on success, or FALSE on failure.

    The keys of the returned array have the following meanings:

    | | --- | --- | | PHP Version: | 5.1+ |

    PHP Date/Time PHP Date/Time Reference Manual