The strptime() function is an inbuilt function in PHP which is used to parse a time / date generated with strftime() function. The date and format are sent as a parameter to the strptime() function and it returns an array on success or False on failure. The array returned by the strptime() function contains the following parameters:
- tm_sec: It denotes the seconds after the minute (0-61).
- tm_min: It denotes the minutes after the hour (0-59)
- tm_hour: It denotes the hour since midnight (0-23)
- tm_mday: It denotes the day of the month (1-31)
- tm_mon: It denotes the months since January (0-11)
- tm_year: It denotes the years since 1900
- tm_wday: It denotes the days since Sunday (0-6)
- tm_yday: It denotes the days since January 1 (0-365)
- unparsed: It denotes the date part which was not recognized using the specified format
array strptime( $date, $format )
Parameters: This function accepts two parameter as mentioned above and described below:
- $date: It is a mandatory parameter which specifies the string to parse.
- $format: It is a mandatory parameter which specifies the format used in the date.
Return Value: This function returns an array on success or False on failure.
Below programs illustrate the strptime() function in PHP:
22/08/2018 11:46:57Array ( [tm_sec] => 57 [tm_min] => 46 [tm_hour] => 11 [tm_mday] => 22 [tm_mon] => 7 [tm_year] => 118 [tm_wday] => 3 [tm_yday] => 233 [unparsed] => )
22/08/18 11:46:59Array ( [tm_sec] => 59 [tm_min] => 46 [tm_hour] => 11 [tm_mday] => 22 [tm_mon] => 7 [tm_year] => 118 [tm_wday] => 3 [tm_yday] => 233 [unparsed] => )
- How to get the function name inside a function in PHP ?
- p5.js | hex() function
- PHP | Ds\Map first() Function
- D3.js | d3.rgb() Function
- PHP | end() Function
- D3.js | d3.hcl() Function
- D3.js | d3.lab() Function
- p5.js | value() Function
- CSS | var() Function
- PHP | each() Function
- CSS | hsl() Function
- PHP | dir() Function
- PHP | Ds\Set xor() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.