Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 2560

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>strtotime</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Date and Time functions"
HREF="ref.datetime.html"><LINK
REL="PREVIOUS"
TITLE="strftime"
HREF="function.strftime.html"><LINK
REL="NEXT"
TITLE="time"
HREF="function.time.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.strftime.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.time.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.strtotime"
></A
>strtotime</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN17104"
></A
><P
>    (PHP 3&#62;= 3.0.12, PHP 4 )</P
>strtotime&nbsp;--&nbsp;
     Parse about any English textual datetime description into a UNIX
     timestamp
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN17107"
></A
><H2
>Description</H2
>int <B
CLASS="methodname"
>strtotime</B
> ( string time [, int now])<BR
></BR
><P
>&#13;     The function expects to be given a string containing an English date
     format and will try to parse that format into a UNIX timestamp relative
     to the timestamp given in <TT
CLASS="parameter"
><I
>now</I
></TT
>, or the current time
     if none is supplied. Upon failure, <TT
CLASS="literal"
>-1</TT
> is returned.
    </P
><P
>&#13;     Because <B
CLASS="function"
>strtotime()</B
> behaves according to GNU
     date syntax, have a look at the GNU manual page titled
     <A
HREF="http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html"
TARGET="_top"
>Date Input Formats</A
>.
     Described there is valid syntax for the <TT
CLASS="parameter"
><I
>time</I
></TT
> 
     parameter.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN17126"
></A
><P
><B
>Example 1. <B
CLASS="function"
>strtotime()</B
> examples</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>echo strtotime ("now"), "\n";
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";
echo strtotime ("next Thursday"), "\n";
echo strtotime ("last Monday"), "\n";</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN17131"
></A
><P
><B
>Example 2. Checking for failure</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>$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);
}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      The valid range of a timestamp is typically from Fri, 13 Dec
      1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are
      the dates that correspond to the minimum and maximum values for
      a 32-bit signed integer.)
     </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.strftime.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.time.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>strftime</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.datetime.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>time</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>