<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.datetime.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.gmstrftime.php',
    1 => 'gmstrftime',
    2 => '根据区域设置格式化 GMT/UTC 时间/日期',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => 'Date/Time 函数',
  ),
  'prev' => 
  array (
    0 => 'function.gmmktime.php',
    1 => 'gmmktime',
  ),
  'next' => 
  array (
    0 => 'function.idate.php',
    1 => 'idate',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/datetime/functions/gmstrftime.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.gmstrftime" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gmstrftime</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gmstrftime</span> &mdash; <span class="dc-title">根据区域设置格式化 GMT/UTC 时间/日期</span></p>

 </div>

 <div id="function.gmstrftime-refsynopsisdiv">
  <div class="warning"><strong class="warning">警告</strong><p class="simpara"> 该函数自 PHP 8.1
起<em>弃用</em>。强烈建议不要依赖此函数。</p>
</div>
<p class="para">
 此函数可以使用如下替代：
</p>

  <ul class="simplelist">
   <li><span class="function"><a href="function.gmdate.php" class="function">gmdate()</a></span></li>
   <li><span class="methodname"><a href="intldateformatter.format.php" class="methodname">IntlDateFormatter::format()</a></span></li>
  </ul>
 </div>

 <div class="refsect1 description" id="refsect1-function.gmstrftime-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
   <span class="methodname"><strong>gmstrftime</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$format</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$timestamp</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   行为和 <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span> 相同，只是返回的时间是格林威治标准时（GMT）。例如，在东部标准时（EST，GMT
   -0500）运行时，下面第一行显示“Dec 31 1998 20:00:00”，而第二行显示“Jan 01 1999
   01:00:00”。
  </p>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    此函数依赖于操作系统区域设置信息，这些信息可能彼此不一致，或者根本不能用。而是使用
    <span class="methodname"><a href="intldateformatter.format.php" class="methodname">IntlDateFormatter::format()</a></span> 方法。
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.gmstrftime-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">format</code></dt>
     <dd>
      <p class="para">
       See description in <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span>.
      </p>
     </dd>
    
    <dt><code class="parameter">timestamp</code></dt><dd><p class="para">
可选的 <code class="parameter">timestamp</code> 参数是一个 <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> 的 Unix
时间戳，如未指定或是 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>，参数值默认为当前本地时间。也就是说，其值默认为
<span class="function"><a href="function.time.php" class="function">time()</a></span> 的返回值。</p></dd>
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gmstrftime-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   根据指定的格式字符串使用指定的 <code class="parameter">timestamp</code>
   或当前本地时间（若未提供时间戳）返回格式化的字符串。月份、星期名称及其他与语言相关的字符串遵循通过
   <span class="function"><a href="function.setlocale.php" class="function">setlocale()</a></span> 设置的当前区域。失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.gmstrftime-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        现在 <code class="parameter">timestamp</code> 允许为 null。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.gmstrftime-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>gmstrftime()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_TIME</span><span style="color: #007700">, </span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">strftime</span><span style="color: #007700">(</span><span style="color: #DD0000">"%b %d %Y %H:%M:%S"</span><span style="color: #007700">, </span><span style="color: #0000BB">mktime</span><span style="color: #007700">(</span><span style="color: #0000BB">20</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">12</span><span style="color: #007700">, </span><span style="color: #0000BB">31</span><span style="color: #007700">, </span><span style="color: #0000BB">98</span><span style="color: #007700">)) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">gmstrftime</span><span style="color: #007700">(</span><span style="color: #DD0000">"%b %d %Y %H:%M:%S"</span><span style="color: #007700">, </span><span style="color: #0000BB">mktime</span><span style="color: #007700">(</span><span style="color: #0000BB">20</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">12</span><span style="color: #007700">, </span><span style="color: #0000BB">31</span><span style="color: #007700">, </span><span style="color: #0000BB">98</span><span style="color: #007700">)) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.gmstrftime-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="intldateformatter.format.php" class="methodname" rel="rdfs-seeAlso">IntlDateFormatter::format()</a> - Format the date/time value as a string</span></li>
    <li><span class="methodname"><a href="datetime.format.php" class="methodname" rel="rdfs-seeAlso">DateTimeInterface::format()</a> - 按照指定格式返回格式化后的日期</span></li>
    <li><span class="function"><a href="function.strftime.php" class="function" rel="rdfs-seeAlso">strftime()</a> - 根据区域设置格式化本地时间/日期</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>