mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Updating per errata notes, adding examples.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@43153 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
144cfff273
commit
faa617e4fd
1 changed files with 61 additions and 1 deletions
|
@ -251,6 +251,31 @@ $nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);
|
|||
</programlisting>
|
||||
</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>
|
||||
|
@ -335,6 +360,18 @@ $nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);
|
|||
</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 @@ echo gmstrftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n";
|
|||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
"tm_year" - Year, not y2k compliant
|
||||
"tm_year" - Years since 1900
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
|
@ -592,6 +629,29 @@ echo gmstrftime ("%b %d %Y %H:%M:%S", mktime (20,0,0,12,31,98))."\n";
|
|||
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>.
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue