intldateformatter.parse.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 164 行

HTML
164
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Parse string to a timestamp value</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="intldateformatter.localtime.html">IntlDateFormatter::localtime</a></div> <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.setcalendar.html">IntlDateFormatter::setCalendar</a></div> <div class="up"><a href="class.intldateformatter.html">IntlDateFormatter</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="intldateformatter.parse" class="refentry"> <div class="refnamediv">  <h1 class="refname">IntlDateFormatter::parse</h1>  <h1 class="refname">datefmt_parse</h1>  <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">IntlDateFormatter::parse</span> -- <span class="refname">datefmt_parse</span> &mdash; <span class="dc-title">Parse string to a timestamp value</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <p class="para">	Object oriented style  </p>   <div class="methodsynopsis dc-description">   <span class="type">integer</span> <span class="methodname"><b><b>IntlDateFormatter::parse</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$value</tt></span>   [, <span class="methodparam"><span class="type">integer</span> <tt class="parameter reference">&$position</tt></span>   ] )</div>  <p class="para rdfs-comment">	Procedural style  </p>  <div class="methodsynopsis dc-description">   <span class="type">integer</span> <span class="methodname"><b><b>datefmt_parse</b></b></span>   ( <span class="methodparam"><span class="type"><a href="class.intldateformatter.html" class="type IntlDateFormatter">IntlDateFormatter</a></span> <tt class="parameter">$fmt</tt></span>  , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$value</tt></span>  [, <span class="methodparam"><span class="type">integer</span> <tt class="parameter reference">&$position</tt></span>  ] )</div>  <p class="para rdfs-comment">   Converts string $value to an incremental time value, starting at    $parse_pos and consuming as much of the input value as possible.  </p>   </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">fmt</tt></i></span>     <dd>      <p class="para">	  The formatter resource            </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">value</tt></i></span>     <dd>      <p class="para">	  string to convert to a time       </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">position</tt></i></span>     <dd>      <p class="para">	  Position at which to start the parsing in $value (zero-based).	  If no error occurs before $value is consumed, $parse_pos will contain -1otherwise it will contain the position at which parsing ended (and the error occurred).          This variable will contain the end position if the parse fails.	  If $parse_pos &gt; strlen($value), the parse fails immediately.       </p>     </dd>    </dt>   </dl>  </p> </div>     <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   timestamp  parsed value    </p> </div>  <div class="refsect1 examples">  <h3 class="title">Examples</h3>   <div class="example">    <p><b>Example #1 <b>datefmt_parse()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"en_US"&nbsp;</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #DD0000">'America/Los_Angeles'</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">GREGORIAN&nbsp;&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"First&nbsp;parsed&nbsp;output&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">parse</span><span style="color: #007700">(</span><span style="color: #DD0000">"Wednesday,&nbsp;December&nbsp;31,&nbsp;1969&nbsp;4:00:00&nbsp;PM&nbsp;PT"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fmt&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"de-DE"&nbsp;</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #DD0000">'America/Los_Angeles'</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">GREGORIAN&nbsp;&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Second&nbsp;parsed&nbsp;output&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">parse</span><span style="color: #007700">(</span><span style="color: #DD0000">"Mittwoch,&nbsp;31.&nbsp;Dezember&nbsp;1969&nbsp;16:00&nbsp;Uhr&nbsp;GMT-08:00"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>   <div class="example">    <p><b>Example #2 OO example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">datefmt_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"en_US"&nbsp;</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #DD0000">'America/Los_Angeles'</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">GREGORIAN&nbsp;&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"First&nbsp;parsed&nbsp;output&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">datefmt_parse</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fmt&nbsp;</span><span style="color: #007700">,&nbsp;&nbsp;</span><span style="color: #DD0000">"Wednesday,&nbsp;December&nbsp;20,&nbsp;1989&nbsp;4:00:00&nbsp;PM&nbsp;PT"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">datefmt_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"de-DE"&nbsp;</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,</span><span style="color: #DD0000">'America/Los_Angeles'</span><span style="color: #007700">,</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">GREGORIAN&nbsp;&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Second&nbsp;parsed&nbsp;output&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">datefmt_parse</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">$fmt&nbsp;</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Mittwoch,&nbsp;20.&nbsp;Dezember&nbsp;1989&nbsp;16:00&nbsp;Uhr&nbsp;GMT-08:00"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>     <p class="para">The above example will output:</p>     <div class="example-contents"><pre>         <div class="cdata"><pre>First parsed output is 630201600Second parsed output is 630201600</pre></div>     </pre></div> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="intldateformatter.create.html" class="function" rel="rdfs-seeAlso">datefmt_create()</a></li>    <li class="member"><a href="intldateformatter.format.html" class="function" rel="rdfs-seeAlso">datefmt_format()</a></li>    <li class="member"><a href="intldateformatter.localtime.html" class="function" rel="rdfs-seeAlso">datefmt_localtime()</a></li>    <li class="member"><a href="intldateformatter.geterrorcode.html" class="function" rel="rdfs-seeAlso">datefmt_get_error_code()</a></li>    <li class="member"><a href="intldateformatter.geterrormessage.html" class="function" rel="rdfs-seeAlso">datefmt_get_error_message()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="intldateformatter.localtime.html">IntlDateFormatter::localtime</a></div> <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.setcalendar.html">IntlDateFormatter::setCalendar</a></div> <div class="up"><a href="class.intldateformatter.html">IntlDateFormatter</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?