Removed the reference to "US English" in the strtotime() description, since

that's not true for all delimiters, and added an explanatory note summarising
the Date and Time Formats grammar and how it pertains to m/d/y and d-m-y, along
with a recommendation to use ISO 8601 or DateTime::createFromFormat() where
possible.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@305220 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Adam Harvey 2010-11-09 10:53:51 +00:00
parent 249c8aa087
commit ef151ba6c1

View file

@ -14,11 +14,11 @@
<methodparam choice="opt"><type>int</type><parameter>now</parameter></methodparam>
</methodsynopsis>
<simpara>
The function expects to be given a string containing a US English date
format and will try to parse that format into a Unix timestamp (the
number of seconds since January 1 1970 00:00:00 UTC), relative
to the timestamp given in <parameter>now</parameter>, or the current time
if <parameter>now</parameter> is not supplied.
The function expects to be given a string containing an English date format
and will try to parse that format into a Unix timestamp (the number of
seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given
in <parameter>now</parameter>, or the current time if
<parameter>now</parameter> is not supplied.
</simpara>
<para>
This function will use the <envar>TZ</envar> environment variable (if
@ -199,12 +199,28 @@ if (($timestamp = strtotime($str)) === false) {
newer versions overcome this limitation though.
</para>
</note>
<note>
<para>
Dates in the <literal>m/d/y</literal> or <literal>d-m-y</literal> formats
are disambiguated by looking at the separator between the various
components: if the separator is a slash (<literal>/</literal>), then the
American <literal>m/d/y</literal> is assumed; whereas if the separator is a
dash (<literal>-</literal>) or a dot (<literal>.</literal>), then the
European <literal>d-m-y</literal> format is assumed.
</para>
<para>
To avoid potential ambiguity, it's best to use ISO 8601
(<literal>YYYY-MM-DD</literal>) dates or
<function>DateTime::createFromFormat</function> when possible.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>DateTime::createFromFormat</function></member>
<member><function>strptime</function></member>
</simplelist>
</para>