$date
, string $format
): array
strptime() 返回一個(gè)將
date
解析后的數(shù)組,如果出錯(cuò)返回 false
。
月份和星期幾的名字以及其它與語(yǔ)種有關(guān)的字符串對(duì)應(yīng)于
setlocale()設(shè)定的當(dāng)前區(qū)域(LC_TIME
)。
date
(string)被解析的字符串(例如從 strftime() 返回的)
format
(string)
date
所使用的格式(例如同
strftime() 中所使用的相同)。
更多有關(guān)格式選項(xiàng)的信息見 strftime() 頁(yè)面。
返回一個(gè)數(shù)組 或者在失敗時(shí)返回 false
鍵名 | 說明 |
---|---|
tm_sec | 當(dāng)前分鐘內(nèi)的秒數(shù)(0-61) |
tm_min | 當(dāng)前小時(shí)內(nèi)的分鐘數(shù)(0-59) |
tm_hour | 午夜起的小時(shí)數(shù)(0-23) |
tm_mday | 月份中的第幾天(1-31) |
tm_mon | 自一月起過了幾個(gè)月(0-11) |
tm_year | 自 1900 年起過了幾年 |
tm_wday | 自星期天起過了幾天(0-6) |
tm_yday | 本年自一月一日起過了多少天(0-365) |
unparsed | date 中未能通過指定的
format 識(shí)別的部分 |
示例 #1 strptime() 例子
<?php
$format = '%d/%m/%Y %H:%M:%S';
$strf = strftime($format);
echo "$strf\n";
print_r(strptime($strf, $format));
?>
以上例程的輸出類似于:
03/10/2004 15:54:19 Array ( [tm_sec] => 19 [tm_min] => 54 [tm_hour] => 15 [tm_mday] => 3 [tm_mon] => 9 [tm_year] => 104 [tm_wday] => 0 [tm_yday] => 276 [unparsed] => )
注意: 此函數(shù)未在 Windows 平臺(tái)下實(shí)現(xiàn)。
注意:
Internally, this function calls the
strptime()
function provided by the system's C library. This function can exhibit noticeably different behaviour across different operating systems. The use of date_parse_from_format(), which does not suffer from these issues, is recommended on PHP 5.3.0 and later.
注意:
"tm_sec"
includes any leap seconds (currently upto 2 a year). For more information on leap seconds, see the ? Wikipedia article on leap seconds.
注意:
Prior to PHP 5.2.0, this function could return undefined behaviour. Notably, the
"tm_sec"
,"tm_min"
and"tm_hour"
entries would return undefined values.