2009-11-19 13:13:35 +00:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
2009-07-11 06:46:52 +00:00
|
|
|
<!-- $Revision$ -->
|
2009-10-28 09:35:54 +00:00
|
|
|
<refentry xml:id="function.strptime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
2004-09-29 15:39:54 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>strptime</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Parse a time/date generated with <function>strftime</function>
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
2007-01-16 01:24:43 +00:00
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2004-09-29 15:39:54 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>array</type><methodname>strptime</methodname>
|
2005-09-02 16:39:25 +00:00
|
|
|
<methodparam><type>string</type><parameter>date</parameter></methodparam>
|
2004-09-29 15:39:54 +00:00
|
|
|
<methodparam><type>string</type><parameter>format</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
2004-10-03 15:53:48 +00:00
|
|
|
<para>
|
|
|
|
<function>strptime</function> returns an array with the
|
2005-09-02 16:39:25 +00:00
|
|
|
<parameter>date</parameter> parsed, or &false; on error.
|
2004-10-03 15:53:48 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Month and weekday names and other language dependent strings respect the
|
2009-05-03 12:27:22 +00:00
|
|
|
current locale set with <function>setlocale</function> (<constant>LC_TIME</constant>).
|
2005-09-02 16:39:25 +00:00
|
|
|
</para>
|
2004-10-03 15:53:48 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2005-09-02 16:39:25 +00:00
|
|
|
<term><parameter>date</parameter> (<type>string</type>)</term>
|
2004-10-03 15:53:48 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2010-08-20 05:45:06 +00:00
|
|
|
The string to parse (e.g. returned from <function>strftime</function>).
|
2004-10-03 15:53:48 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>format</parameter> (<type>string</type>)</term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2005-09-02 19:26:14 +00:00
|
|
|
The format used in <parameter>date</parameter> (e.g. the same as
|
2010-08-20 05:45:06 +00:00
|
|
|
used in <function>strftime</function>). Note that some of the format
|
|
|
|
options available to <function>strftime</function> may not have any
|
|
|
|
effect within <function>strptime</function>; the exact subset that are
|
|
|
|
supported will vary based on the operating system and C library in
|
|
|
|
use.
|
2004-10-03 15:53:48 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
For more information about the format options, read the
|
|
|
|
<function>strftime</function> page.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
2009-11-09 10:26:08 +00:00
|
|
|
Returns an array&return.falseforfailure;.
|
2004-10-03 15:53:48 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<table>
|
|
|
|
<title>The following parameters are returned in the array</title>
|
|
|
|
<tgroup cols="2">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>parameters</entry>
|
|
|
|
<entry>Description</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_sec"</literal></entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
<entry>Seconds after the minute (0-61)</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_min"</literal></entry>
|
2004-10-03 16:11:24 +00:00
|
|
|
<entry>Minutes after the hour (0-59)</entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
</row>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_hour"</literal></entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
<entry>Hour since midnight (0-23)</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_mday"</literal></entry>
|
2004-10-03 16:11:24 +00:00
|
|
|
<entry>Day of the month (1-31)</entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
</row>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_mon"</literal></entry>
|
2004-10-03 16:11:24 +00:00
|
|
|
<entry>Months since January (0-11)</entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
</row>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_year"</literal></entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
<entry>Years since 1900</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_wday"</literal></entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
<entry>Days since Sunday (0-6)</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"tm_yday"</literal></entry>
|
2004-10-03 15:53:48 +00:00
|
|
|
<entry>Days since January 1 (0-365)</entry>
|
|
|
|
</row>
|
2004-10-04 10:07:51 +00:00
|
|
|
<row>
|
2009-05-03 12:27:22 +00:00
|
|
|
<entry><literal>"unparsed"</literal></entry>
|
2005-09-02 19:26:14 +00:00
|
|
|
<entry>the <parameter>date</parameter> part which was not
|
2004-10-04 10:07:51 +00:00
|
|
|
recognized using the specified <parameter>format</parameter></entry>
|
|
|
|
</row>
|
2004-10-03 15:53:48 +00:00
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
|
|
|
</table>
|
|
|
|
</para>
|
2005-09-02 19:26:14 +00:00
|
|
|
|
2004-10-03 15:53:48 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>strptime</function> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
$format = '%d/%m/%Y %H:%M:%S';
|
|
|
|
$strf = strftime($format);
|
|
|
|
|
|
|
|
echo "$strf\n";
|
|
|
|
|
|
|
|
print_r(strptime($strf, $format));
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
&example.outputs.similar;
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
03/10/2004 15:54:19
|
2004-09-29 15:39:54 +00:00
|
|
|
|
2004-10-03 15:53:48 +00:00
|
|
|
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] =>
|
|
|
|
)
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2004-09-29 15:39:54 +00:00
|
|
|
|
2008-05-28 04:42:07 +00:00
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
|
|
|
¬e.no-windows;
|
2010-08-20 05:45:06 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
Internally, this function calls the <literal>strptime()</literal>
|
|
|
|
function provided by the system's C library. This function can exhibit
|
|
|
|
noticeably different behaviour across different operating systems. The
|
|
|
|
use of <function>date_parse_from_format</function>, which does not
|
|
|
|
suffer from these issues, is recommended on PHP 5.3.0 and later.
|
|
|
|
</para>
|
|
|
|
</note>
|
2009-10-28 09:35:54 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
<literal>"tm_sec"</literal> includes any leap seconds (currently upto 2
|
|
|
|
a year). For more information on leap seconds, see the <link
|
2009-11-03 02:15:21 +00:00
|
|
|
xlink:href="&url.wiki.leap-seconds;">Wikipedia article
|
2009-10-28 09:35:54 +00:00
|
|
|
on leap seconds</link>.
|
|
|
|
</para>
|
|
|
|
</note>
|
2010-10-20 00:33:12 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
2010-10-25 19:38:17 +00:00
|
|
|
Prior to PHP 5.2.0, this function could return undefined behaviour. Notably,
|
2010-10-20 00:33:12 +00:00
|
|
|
the <literal>"tm_sec"</literal>, <literal>"tm_min"</literal> and <literal>"tm_hour"</literal>
|
|
|
|
entries would return undefined values.
|
|
|
|
</para>
|
|
|
|
</note>
|
2008-05-28 04:42:07 +00:00
|
|
|
</refsect1>
|
|
|
|
|
2004-10-03 15:53:48 +00:00
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
2011-03-10 07:13:07 +00:00
|
|
|
<member><function>checkdate</function></member>
|
2004-10-03 15:53:48 +00:00
|
|
|
<member><function>strftime</function></member>
|
2011-10-31 21:49:35 +00:00
|
|
|
<member><function>date_parse_from_format</function></member>
|
2011-09-24 09:29:52 +00:00
|
|
|
<member><function>DateTime::createFromFormat</function></member>
|
2004-10-03 15:53:48 +00:00
|
|
|
</simplelist>
|
|
|
|
</para>
|
2004-09-29 15:39:54 +00:00
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2004-09-29 15:39:54 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|