PHP | strptime() Function Last Updated : 22 Aug, 2018 Comments Improve Suggest changes Like Article Like Report 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 Syntax: 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: Program 1: php <?php // Declaring the format of date/time $format = "%d/%m/%Y %H:%M:%S"; // Parsing the date/time $dt = strftime( $format ); echo "$dt"; print_r(strptime( $dt, $format )); ?> Output: 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] => ) Program 2: php <?php // Ddeclaring a different format of date/time $format="%d/%m/%y %I:%M:%S"; // Parsing the date/time $dt = strftime( $format ); echo "$dt"; print_r(strptime( $dt, $format )); ?> Output: 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] => ) Related Articles: PHP | gmdate() Function PHP | date_parse() Function Reference: http://php.net/manual/en/function.strptime.php Comment More infoAdvertise with us Next Article PHP | strptime() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time PHP-function +1 More Practice Tags : Misc Similar Reads PHP | strftime() Function The strftime() function is an inbuilt function in PHP that formats local time or date according to locale settings i.e. it formats local time or date for location set for it of a place. Syntax: strftime( $format, $timestamp ) Parameters: This function accept two parameters as mentioned above and des 5 min read PHP | strtotime() Function The strtotime() function is a built-in function in PHP which is used to convert an English textual date-time description to a UNIX timestamp. The function accepts a string parameter in English which represents the description of date-time. For e.g., "now" refers to the current date in English date-t 2 min read PHP | time() Function The time() function is a built-in function in PHP which returns the current time measured in the number of seconds since the Unix Epoch. The number of seconds can be converted to the current date using date() function in PHP. Syntax: int time() Parameter: This function does not accepts any parameter 2 min read PHP | date_time_set() Function The date_time_set() function is an inbuilt function in PHP which is used to sets the time. This function resets the current time of the DateTime object to a different time. Syntax: Procedural style: date_time_set( $object, $hour, $minute, $second, $microseconds ) Object oriented style: DateTime::set 2 min read PHP | time_sleep_until( ) Function The time_sleep_until() function in PHP is an inbuilt function which is used to delay execution of the current script until the specified time. The time_sleep_until( ) function accepts timestamp as a parameter and this timestamp denotes when the script should wake. The time_sleep_until( ) function re 2 min read Like