strptime() - 语法
array strptime ( string $date, string $format );
此函数返回一个包含解析日期的数组,如果出现错误,则返回False。
数组中返回以下参数。
- [tm_sec] - seconds (0-61)
- [tm_min] - minutes (0-59)
- [tm_hour] - hour (0-23)
- [tm_mday] - day of the month (1-31)
- [tm_mon] - months since January (0-11)
- [tm_year] - years since 1900
- [tm_wday] - days since Sunday (0-6)
- [tm_yday] - days since January 1 (0-365)
- [unparsed] - the date part which was not recognized using the specified format, if any
Sr.No | Parameter & Description |
---|---|
1 |
date(必需) 要解析的字符串(例如,从strftime()返回) |
2 |
format(必需) Date中使用的格式,并使用以下-进行格式化
|
strptime() - 返回值
它返回一个数组,如果失败,则返回FALSE。
strptime() - 示例
<?php $format='%d/%m/%Y %H:%M:%S'; $strf=strftime($format); echo "$strf\n"; print_r(strptime($strf, $format)); ?>
这将产生以下输出-
07/12/2016 09:08:03 Array ( [tm_sec] => 3 [tm_min] => 8 [tm_hour] => 9 [tm_mday] => 7 [tm_mon] => 11 [tm_year] => 116 [tm_wday] => 3 [tm_yday] => 341 [unparsed] => )