mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
159 lines
5.5 KiB
HTML
159 lines
5.5 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>将本地时间日期格式化为整数</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.idate" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">idate</h1>
|
||
<p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">idate</span> — <span class="dc-title">将本地时间日期格式化为整数</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 unknown-unknown-unknown-unknown-examplew" id="refsect1-function.idate-unknown-unknown-unknown-unknown-examplew">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>idate</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$format</code></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$timestamp</code></span>
|
||
] ) : <span class="type">int</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
根据给定的格式字符对 <code class="parameter">timestamp</code>
|
||
格式化并返回数字结果。<code class="parameter">timestamp</code>
|
||
为可选项,默认值为本地当前时间,即 <span class="function"><a href="time.html" class="function">time()</a></span> 的值。
|
||
</p>
|
||
<p class="para">
|
||
和 <span class="function"><a href="date.html" class="function">date()</a></span> 不同,<span class="function"><strong>idate()</strong></span>
|
||
只接受一个字符作为 <code class="parameter">format</code> 参数。
|
||
</p>
|
||
<p class="para">
|
||
<table class="doctable table">
|
||
<caption><strong><code class="parameter">format</code> 参数可识别以下字符</strong></caption>
|
||
|
||
<thead>
|
||
<tr>
|
||
<th><code class="parameter">format</code> 字符</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td><em>B</em></td>
|
||
<td>Swatch Beat/Internet Time</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>d</em></td>
|
||
<td>月份中的第几天</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>h</em></td>
|
||
<td>小时(12 小时格式)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>H</em></td>
|
||
<td>小时(24 小时格式)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>i</em></td>
|
||
<td>分钟</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>I</em></td>
|
||
<td>如果启用夏时制则返回 <em>1</em>,否则返回 <em>0</em></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>L</em></td>
|
||
<td>如果是闰年则返回 <em>1</em>,否则返回 <em>0</em></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>m</em></td>
|
||
<td>月份的数字</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>s</em></td>
|
||
<td>秒数</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>t</em></td>
|
||
<td>本月的总天数</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>U</em></td>
|
||
<td>自 Unix 纪元(January 1 1970 00:00:00
|
||
GMT)起的秒数——这和 <span class="function"><a href="time.html" class="function">time()</a></span> 作用相同</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>w</em></td>
|
||
<td>星期中的第几天(星期天是 <em>0</em>)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>W</em></td>
|
||
<td>ISO-8601 格式年份中的第几个星期,每星期从星期一开始</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>y</em></td>
|
||
<td>年份(1 或 2 位数字——见下面说明)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>Y</em></td>
|
||
<td>年份(4 位数字)</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>z</em></td>
|
||
<td>年份中的第几天</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><em>Z</em></td>
|
||
<td>以秒为单位的时区偏移量</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
因为 <span class="function"><strong>idate()</strong></span> 总是返回
|
||
<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>,不能以“0”开头,因此 <span class="function"><strong>idate()</strong></span>
|
||
可能会返回比用户期望中要少的数字。见下面例子:
|
||
</p>
|
||
</p></blockquote>
|
||
<p class="para">
|
||
<div class="informalexample">
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br />$timestamp </span><span style="color: #007700">= </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">'1st January 2004'</span><span style="color: #007700">); </span><span style="color: #FF8000">//1072915200<br /><br />// 下面以两位数字格式显示年份,但是因为<br />// 以“0”打头,因此只会显示“4”<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">idate</span><span style="color: #007700">(</span><span style="color: #DD0000">'y'</span><span style="color: #007700">, </span><span style="color: #0000BB">$timestamp</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
<p class="para">
|
||
参见 <span class="function"><a href="date.html" class="function">date()</a></span> 和
|
||
<span class="function"><a href="time.html" class="function">time()</a></span>。
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |