strtotime() returns -1 upon failure, added another example too.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@62978 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2001-11-21 23:21:30 +00:00
parent 65a93a86a8
commit 62af7d467f

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.53 $ -->
<!-- $Revision: 1.54 $ -->
<reference id="ref.datetime">
<title>Date and Time functions</title>
<titleabbrev>Date/time</titleabbrev>
@ -1111,7 +1111,7 @@ print (strftime ("%A.\n"));
<para>
The function expects to be given a string containing an english
date format and will try to parse that format into a UNIX
timestamp.
timestamp. Upon failure, <literal>-1</literal> is returned.
<example>
<title><function>strtotime</function> examples</title>
<programlisting role="php">
@ -1121,6 +1121,21 @@ echo strtotime ("10 September 2000") . "\n";
echo strtotime ("+1 day") . "\n";
echo strtotime ("+1 week") . "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds") . "\n";
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Checking for failure</title>
<programlisting role="php">
<![CDATA[
$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
echo "The string ($str) is bogus";
} else {
echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
}
]]>
</programlisting>
</example>