cvs: phpdoc /en/functions datetime.xml

From: Date: Sat, 10 Mar 2001 23:32:57 +0000
Subject: cvs: phpdoc /en/functions datetime.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969334631@lists.php.net to get a copy of this message
ronabop Sat Mar 10 15:32:57 2001 EDT Modified files: /phpdoc/en/functions datetime.xml Log: Updating per errata notes, adding examples. Index: phpdoc/en/functions/datetime.xml diff -u phpdoc/en/functions/datetime.xml:1.30 phpdoc/en/functions/datetime.xml:1.31 --- phpdoc/en/functions/datetime.xml:1.30 Mon Jan 22 19:25:46 2001 +++ phpdoc/en/functions/datetime.xml Sat Mar 10 15:32:57 2001 @@ -252,6 +252,31 @@ </example> </para> <para> + Some examples of <function>date</function> formatting. Note that + you should escape any other characters, as any which currently + have a special meaning will produce undesirable results, and + other characters may be assigned meaning in future PHP versions. + When escaping, bu sure to use single quotes to prevent characters + like \n from become newlines. + <example> + <title> + <function>Date</function> Formatting + </title> + <programlisting> +/* Today is March 10th, 2001, 5:16:18 pm */ +$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm +$today = date("m.d.y"); // 03.10.01 +$today = date("j, g, Y"); // 10, 3, 2001 +$today = date("Ymd"); // 20010310 +$today = date('h-i-s, j-m-y, it is w Day z '); // 05-16-17, 10-03-01, 1631 1618 6 Fripm01 +$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // It is the 10th day. +$today = date("D M j g:i:s T Y"); // Sat Mar 10 15:16:08 MST 2001 +$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:17 m is month +$today = date("H:i:s"); // 17:16:17 + </programlisting> + </example> + </para> + <para> To format dates in other languages, you should use the <function>setlocale</function> and <function>strftime</function> functions. @@ -335,6 +360,18 @@ </simpara> </listitem> </itemizedlist> + <example> + <title> + <function>getdate</function> example + </title> + <programlisting> +$today = getdate(); +$month = $today[month]; +$mday = $today[mday]; +$year = $today[year]; +echo "$month $mday, $year"; + </programlisting> + </example> </para> </refsect1> </refentry> @@ -548,7 +585,7 @@ </listitem> <listitem> <simpara> - "tm_year" - Year, not y2k compliant + "tm_year" - Years since 1900 </simpara> </listitem> <listitem> @@ -591,6 +628,29 @@ January 1, 1970 GMT), and msec is the microseconds part. This function is only available on operating systems that support the gettimeofday() system call. + </para> + <para> + Both portions of the string are returned in units of seconds. + <example> + <title><function>microtime</function> example</title> + <programlisting role="php"> +function getmicrotime(){ + list($sec, $usec) = explode(" ",microtime()); + return ($sec + $usec); + } + +$time_start = getmicrotime(); + +for ($i=0; $i < 1000; $i++){ + //do nothing, 1000 times + } + +$time_end = getmicrotime(); +$time = $time_end - $time_start; + +echo "Did nothing in $time seconds"; + </programlisting> + </example> </para> <para> See also <function>time</function>.

« previous php.doc (#969334631) next »