mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
223 lines
8.8 KiB
HTML
223 lines
8.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>解析由 strftime 生成的日期/时间</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.strptime" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">strptime</h1>
|
||
<p class="verinfo">(PHP 5 >= 5.1.0, PHP 7)</p><p class="refpurpose"><span class="refname">strptime</span> — <span class="dc-title">解析由 <span class="function"><a href="strftime.html" class="function">strftime()</a></span> 生成的日期/时间</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 description" id="refsect1-function.strptime-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>strptime</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$date</code></span>
|
||
, <span class="methodparam"><span class="type">string</span> <code class="parameter">$format</code></span>
|
||
) : <span class="type">array</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>strptime()</strong></span> 返回一个将
|
||
<code class="parameter">date</code> 解析后的数组,如果出错返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
<p class="para">
|
||
月份和星期几的名字以及其它与语种有关的字符串对应于
|
||
<span class="function"><a href="setlocale.html" class="function">setlocale()</a></span>设定的当前区域(<strong><code>LC_TIME</code></strong>)。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.strptime-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">date</code>(<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)</dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
被解析的字符串(例如从 <span class="function"><a href="strftime.html" class="function">strftime()</a></span> 返回的)
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">format</code>(<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)</dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
<code class="parameter">date</code> 所使用的格式(例如同
|
||
<span class="function"><a href="strftime.html" class="function">strftime()</a></span> 中所使用的相同)。
|
||
</p>
|
||
<p class="para">
|
||
更多有关格式选项的信息见 <span class="function"><a href="strftime.html" class="function">strftime()</a></span> 页面。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.strptime-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
返回一个数组 或者在失败时返回 <strong><code>FALSE</code></strong>
|
||
</p>
|
||
|
||
<p class="para">
|
||
<table class="doctable table">
|
||
<caption><strong>数组中包含以下单元</strong></caption>
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>键名</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>tm_sec</td>
|
||
<td>当前分钟内的秒数(0-61)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>tm_min</td>
|
||
<td>当前小时内的分钟数(0-59)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>tm_hour</td>
|
||
<td>午夜起的小时数(0-23)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>tm_mday</td>
|
||
<td>月份中的第几天(1-31)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>tm_mon</td>
|
||
<td>自一月起过了几个月(0-11)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>tm_year</td>
|
||
<td>自 1900 年起过了几年</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>tm_wday</td>
|
||
<td>自星期天起过了几天(0-6)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>tm_yday</td>
|
||
<td>本年自一月一日起过了多少天(0-365)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>unparsed</td>
|
||
<td><code class="parameter">date</code> 中未能通过指定的
|
||
<code class="parameter">format</code> 识别的部分</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.strptime-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-2734">
|
||
<p><strong>Example #1 <span class="function"><strong>strptime()</strong></span> 例子</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br />$format </span><span style="color: #007700">= </span><span style="color: #DD0000">'%d/%m/%Y %H:%M:%S'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$strf </span><span style="color: #007700">= </span><span style="color: #0000BB">strftime</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$strf</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">strptime</span><span style="color: #007700">(</span><span style="color: #0000BB">$strf</span><span style="color: #007700">, </span><span style="color: #0000BB">$format</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
|
||
<div class="example-contents screen">
|
||
<div class="cdata"><pre>
|
||
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] =>
|
||
)
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 notes" id="refsect1-function.strptime-notes">
|
||
<h3 class="title">注释</h3>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数未在 Windows 平台下实现。</span></p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
Internally, this function calls the <em>strptime()</em>
|
||
function provided by the system's C library. This function can exhibit
|
||
noticeably different behaviour across different operating systems. The
|
||
use of <span class="function"><a href="date_parse_from_format.html" class="function">date_parse_from_format()</a></span>, which does not
|
||
suffer from these issues, is recommended on PHP 5.3.0 and later.
|
||
</p>
|
||
</p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
<em>"tm_sec"</em> includes any leap seconds (currently upto 2
|
||
a year). For more information on leap seconds, see the <a href="http://en.wikipedia.org/wiki/Leap_second" class="link external">» Wikipedia article
|
||
on leap seconds</a>.
|
||
</p>
|
||
</p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
Prior to PHP 5.2.0, this function could return undefined behaviour. Notably,
|
||
the <em>"tm_sec"</em>, <em>"tm_min"</em> and <em>"tm_hour"</em>
|
||
entries would return undefined values.
|
||
</p>
|
||
</p></blockquote>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.strptime-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="checkdate.html" class="function" rel="rdfs-seeAlso">checkdate()</a> - 验证一个格里高里日期</span></li>
|
||
<li class="member"><span class="function"><a href="strftime.html" class="function" rel="rdfs-seeAlso">strftime()</a> - 根据区域设置格式化本地时间/日期</span></li>
|
||
<li class="member"><span class="function"><a href="date_parse_from_format.html" class="function" rel="rdfs-seeAlso">date_parse_from_format()</a> - Get info about given date formatted according to the specified format</span></li>
|
||
<li class="member"><span class="function"><a href="datetime.createfromformat.html" class="function" rel="rdfs-seeAlso">DateTime::createFromFormat()</a> - 根据给定的格式解析日期时间字符串</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |