PHP strptime() Function

What is a strptime Function?

Explanation

The "strptime()" function is used to parse a time/date generated with "strftime".

Syntax:




strptime(date,format)



In the above syntax the parameters "date" is the date to be parsed and the "format" specifies the format in which the output is needed.

Example :




<?php
$format="%d/%m/%Y %H:%M:%S";
$strf=strftime($format);
echo("$strf");
print_r(strptime($strf,$format));
?>


Result :


03/10/2005 13:23:44
Array
(
[tm_sec] => 44
[tm_min] => 23
[tm_hour] => 13
[tm_mday] => 3
[tm_mon] => 9
[tm_year] => 105
[tm_wday] => 0
[tm_yday] => 276
[unparsed] =>
)



In the above example the strptime() function is used to return the values of strftime() in an array.

Note :

(PHP 5 >= 5.1.0)

PHP Topics


Ask Questions

Ask Question