Home > Article > Backend Development > strptime() function in PHP
The strptime() function parses the time/date generated using strftime(). This function returns a parsed date array, or FALSE if an error occurs. The following parameters will be returned in an array.
[tm_sec] − Seconds (0-61)
[tm_min] − Minutes (0-59)
[tm_hour] − hour (0-23)
[tm_mday] − day of month (1-31)
[tm_mon] − Number of months since January (0-11)
[tm_year] − Number of years since 1900
[tm_wday] − Number of days since Sunday (0-6)
[tm_yday] − Number of days since January 1 (0-365)
[unparsed] − Use the unrecognized date part (if any) of the specified format
strptime(date, format)
date − The string to parse
format − The format of the date and use the following Format as −
%a − abbreviated day of the week name
##%x − Preferred date representation, excluding time
Return value
<?php $format = '%d/%m/%Y %H:%M:%S'; $strf = strftime($format); echo "$strf</p><p>"; print_r(strptime($strf, $format)); ?>
11/10/2018 05:18:13 Array ( [tm_sec] => 13 [tm_min] => 18 [tm_hour] => 5 [tm_mday] => 11 [tm_mon] => 9 [tm_year] => 118 [tm_wday] => 4 [tm_yday] => 283 [unparsed] => )
The above is the detailed content of strptime() function in PHP. For more information, please follow other related articles on the PHP Chinese website!