cvs: phpdoc /en/reference/datetime/functions strftime.xml

From: Date: Thu, 05 Feb 2009 06:36:46 +0000
Subject: cvs: phpdoc /en/reference/datetime/functions strftime.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-3149@lists.php.net to get a copy of this message
danbrown Thu Feb 5 06:36:46 2009 UTC Modified files: /phpdoc/en/reference/datetime/functions strftime.xml Log: Completely rewrote and formatted table to better-match date(), added undocumented parameter format options, fixed typos, added cross-links, clarified descriptions, etc.

http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/datetime/functions/strftime.xml?r1=1.26&r2=1.27&diff_format=u Index: phpdoc/en/reference/datetime/functions/strftime.xml diff -u phpdoc/en/reference/datetime/functions/strftime.xml:1.26 phpdoc/en/reference/datetime/functions/strftime.xml:1.27 --- phpdoc/en/reference/datetime/functions/strftime.xml:1.26 Fri Jan 9 17:08:52 2009 +++ phpdoc/en/reference/datetime/functions/strftime.xml Thu Feb 5 06:36:46 2009 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.26 $ --> +<!-- $Revision: 1.27 $ --> <refentry xml:id="function.strftime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>strftime</refname> @@ -14,20 +14,20 @@ <methodparam choice="opt"><type>int</type><parameter>timestamp</parameter><initializer>time()</initializer></methodparam> </methodsynopsis> <para> - Format a local time/date according to locale settings. Month and weekday - names and other language dependent strings respect the current locale set + Format the time and/or date according to locale settings. Month and weekday + names and other language-dependent strings respect the current locale set with <function>setlocale</function>. </para> <para> Not all conversion specifiers may be supported by your C library, in which case they will not be supported by PHP's <function>strftime</function>. - Additionally, not all platforms support negative timestamps, therefore your + Additionally, not all platforms support negative timestamps, so your date range may be limited to no earlier than the Unix epoch. This means that - e.g. %e, %T, %R and %D (there might be more) and dates prior to - <literal>Jan 1, 1970</literal> will not work on Windows, some Linux - distributions, and a few other operating systems. For Windows systems a - complete overview of supported conversion specifiers can be found at this - <link xlink:href="&url.strftime.win32;"><acronym>MSDN</acronym> website</link>. + %e, %T, %R and, %D (and possibly others) - as well as dates prior to + <literal>Jan 1, 1970</literal> - will not work on Windows, some Linux + distributions, and a few other operating systems. For Windows systems, a + complete overview of supported conversion specifiers can be found at + <link xlink:href="&url.strftime.win32;"><acronym>MSDN</acronym></link>. </para> </refsect1> @@ -39,225 +39,276 @@ <term><parameter>format</parameter></term> <listitem> <para> - The following conversion specifiers are recognized in the format - string: - <itemizedlist> - <listitem> - <simpara> - %a - abbreviated weekday name according to the current locale - </simpara> - </listitem> - <listitem> - <simpara> - %A - full weekday name according to the current locale - </simpara> - </listitem> - <listitem> - <simpara> - %b - abbreviated month name according to the current locale - </simpara> - </listitem> - <listitem> - <simpara> - %B - full month name according to the current locale - </simpara> - </listitem> - <listitem> - <simpara> - %c - preferred date and time representation for the current - locale - </simpara> - </listitem> - <listitem> - <simpara> - %C - century number (the year divided by 100 and truncated to - an integer, range 00 to 99) - </simpara> - </listitem> - <listitem> - <simpara> - %d - day of the month as a decimal number (range 01 to 31) - </simpara> - </listitem> - <listitem> - <simpara> - %D - same as %m/%d/%y - </simpara> - </listitem> - <listitem> - <simpara> - %e - day of the month as a decimal number, a single digit is - preceded by a space (range ' 1' to '31') - </simpara> - </listitem> - <listitem> - <simpara> - %g - like %G, but without the century. - </simpara> - </listitem> - <listitem> - <simpara> - %G - The 4-digit year corresponding to the ISO week number (see %V). - This has the same format and value as %Y, except that if the ISO week - number belongs to the previous or next year, that year is used - instead. - </simpara> - </listitem> - <listitem> - <simpara> - %h - same as %b - </simpara> - </listitem> - <listitem> - <simpara> - %H - hour as a decimal number using a 24-hour clock (range 00 - to 23) - </simpara> - </listitem> - <listitem> - <simpara> - %I - hour as a decimal number using a 12-hour clock (range 01 - to 12) - </simpara> - </listitem> - <listitem> - <simpara> - %j - day of the year as a decimal number (range 001 to 366) - </simpara> - </listitem> - <listitem> - <simpara> - %m - month as a decimal number (range 01 to 12) - </simpara> - </listitem> - <listitem> - <simpara> - %M - minute as a decimal number - </simpara> - </listitem> - <listitem> - <simpara> - %n - newline character - </simpara> - </listitem> - <listitem> - <simpara> - %p - UPPER-CASE `AM' or `PM' according to the given time value, or - the corresponding strings for the current locale - </simpara> - </listitem> - <listitem> - <simpara> - %P - lower-case `am' or `pm' according to the given time value, or - the corresponding strings for the current locale - </simpara> - </listitem> - <listitem> - <simpara> - %r - time in a.m. and p.m. notation - </simpara> - </listitem> - <listitem> - <simpara> - %R - time in 24 hour notation - </simpara> - </listitem> - <listitem> - <simpara> - %S - second as a decimal number - </simpara> - </listitem> - <listitem> - <simpara> - %t - tab character - </simpara> - </listitem> - <listitem> - <simpara> - %T - current time, equal to %H:%M:%S - </simpara> - </listitem> - <listitem> - <simpara> - %u - weekday as a decimal number [1,7], with 1 representing - Monday - </simpara> - <warning> - <simpara> - Sun Solaris seems to start with Sunday as 1 - although ISO 9889:1999 (the current C standard) clearly - specifies that it should be Monday. - </simpara> - </warning> - </listitem> - <listitem> - <simpara> - %U - week number of the current year as a decimal number, - starting with the first Sunday as the first day of the first - week - </simpara> - </listitem> - <listitem> - <simpara> - %V - The ISO 8601:1988 week number of the current year as a - decimal number, range 01 to 53, where week 1 is the first - week that has at least 4 days in the current year, and with - Monday as the first day of the week. (Use %G or %g for the year - component that corresponds to the week number for the specified - timestamp.) - </simpara> - </listitem> - <listitem> - <simpara> - %W - week number of the current year as a decimal number, - starting with the first Monday as the first day of the first - week - </simpara> - </listitem> - <listitem> - <simpara> - %w - day of the week as a decimal, Sunday being 0 - </simpara> - </listitem> - <listitem> - <simpara> - %x - preferred date representation for the current locale - without the time - </simpara> - </listitem> - <listitem> - <simpara> - %X - preferred time representation for the current locale - without the date - </simpara> - </listitem> - <listitem> - <simpara> - %y - year as a decimal number without a century (range 00 to - 99) - </simpara> - </listitem> - <listitem> - <simpara> - %Y - year as a decimal number including the century - </simpara> - </listitem> - <listitem> - <simpara> - %Z or %z - time zone offset or name or abbreviation (Operating - System dependent) - </simpara> - </listitem> - <listitem> - <simpara> - %% - a literal `%' character - </simpara> - </listitem> - </itemizedlist> + <table> + <title>The following characters are recognized in the + <parameter>format</parameter> parameter string</title> + <tgroup cols="3"> + <thead> + <row> + <entry><parameter>format</parameter></entry> + <entry>Description</entry> + <entry>Example returned values</entry> + </row> + </thead> + <tbody> + <row> + <entry align="center"><emphasis>Day</emphasis></entry> + <entry>---</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%a</literal></entry> + <entry>An abbreviated textual representation of the day</entry> + <entry><literal>Sun</literal> through <literal>Sat</literal></entry> + </row> + <row> + <entry><literal>%A</literal></entry> + <entry>A full textual representation of the day</entry> + <entry><literal>Sunday</literal> through <literal>Saturday</literal></entry> + </row> + <row> + <entry><literal>%d</literal></entry> + <entry>Two-digit day of the month (with leading zeros)</entry> + <entry><literal>01</literal> to <literal>31</literal></entry> + </row> + <row> + <entry><literal>%e</literal></entry> + <entry>Day of the month, with a space preceeding single digits</entry> + <entry><literal> 1</literal> to <literal>31</literal></entry> + </row> + <row> + <entry><literal>%j</literal></entry> + <entry>Day of the year, 3 digits with leading zeros</entry> + <entry><literal>001</literal> to <literal>366</literal></entry> + </row> + <row> + <entry><literal>%u</literal></entry> + <entry>ISO-8601 numeric representation of the day of the week</entry> + <entry><literal>1</literal> (for Monday) though <literal>7</literal> (for Sunday)</entry> + </row> + <row> + <entry><literal>%w</literal></entry> + <entry>Numeric representation of the day of the week</entry> + <entry><literal>0</literal> (for Sunday) through <literal>6</literal> (for Saturday)</entry> + </row> + <row> + <entry align="center"><emphasis>Week</emphasis></entry> + <entry>---</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%U</literal></entry> + <entry>Week number of the given year, starting with the the first + Sunday as the first week</entry> + <entry><literal>13</literal> (for the 13th full week of the year)</entry> + </row> + <row> + <entry><literal>%V</literal></entry> + <entry>ISO-8601:1988 week number of the given year, starting with + the first week of the year with at least 4 weekdays, with Monday + being the start of the week</entry> + <entry><literal>01</literal> through <literal>53</literal> (where 53 + accounts for an overlapping week)</entry> + </row> + <row> + <entry><literal>%W</literal></entry> + <entry>A numeric representation of the week of the year, starting + with the first Monday as the first week</entry> + <entry><literal>46</literal> (for the 46th week of the year beginning + with a Monday)</entry> + </row> + <row> + <entry align="center"><emphasis>Month</emphasis></entry> + <entry>---</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%b</literal></entry> + <entry>Abbreviated month name, based on the locale</entry> + <entry><literal>Jan</literal> through <literal>Dec</literal></entry> + </row> + <row> + <entry><literal>%B</literal></entry> + <entry>Full month name, based on the locale</entry> + <entry><literal>January</literal> through <literal>December</literal></entry> + </row> + <row> + <entry><literal>%h</literal></entry> + <entry>Abbreviated month name, based on the locale (an alias of %b)</entry> + <entry><literal>Jan</literal> through <literal>Dec</literal></entry> + </row> + <row> + <entry><literal>%m</literal></entry> + <entry>Two digit representation of the month</entry> + <entry><literal>01</literal> (for January) through <literal>12</literal> (for December)</entry> + </row> + <row> + <entry align="center"><emphasis>Year</emphasis></entry> + <entry>---</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%C</literal></entry> + <entry>Two digit representation of the century (year divided by 100, truncated to an integer)</entry> + <entry><literal>19</literal> for the 20th Century</entry> + </row> + <row> + <entry><literal>%g</literal></entry> + <entry>Two digit representation of the year going by ISO-8601:1988 standards (see %V)</entry> + <entry>Example: <literal>09</literal> for the week of January 6, 2009</entry> + </row> + <row> + <entry><literal>%G</literal></entry> + <entry>The full four-digit version of %g</entry> + <entry>Example: <literal>2008</literal> for the week of January 3, 2009</entry> + </row> + <row> + <entry><literal>%y</literal></entry> + <entry>Two digit representation of the year</entry> + <entry>Example: <literal>09</literal> for 2009, <literal>79</literal> for 1979</entry> + </row> + <row> + <entry><literal>%Y</literal></entry> + <entry>Four digit representation for the year</entry> + <entry>Example: <literal>2038</literal></entry> + </row> + <row> + <entry align="center"><emphasis>Time</emphasis></entry> + <entry>---</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%H</literal></entry> + <entry>Two digit representation of the hour in 24-hour format</entry> + <entry><literal>00</literal> through <literal>23</literal></entry> + </row> + <row> + <entry><literal>%I</literal></entry> + <entry>Two digit representation of the hour in 12-hour format</entry> + <entry><literal>01</literal> through <literal>12</literal></entry> + </row> + <row> + <entry><literal>%l (lower-case 'L')</literal></entry> + <entry>Hour in 12-hour format, with a space preceeding single digits</entry> + <entry><literal> 1</literal> through <literal>12</literal></entry> + </row> + <row> + <entry><literal>%M</literal></entry> + <entry>Two digit representation of the minute</entry> + <entry><literal>00</literal> through <literal>59</literal></entry> + </row> + <row> + <entry><literal>%p</literal></entry> + <entry>UPPER-CASE 'AM' or 'PM' based on the given time</entry> + <entry>Example: <literal>AM</literal> for 00:31, <literal>PM</literal> for 22:23</entry> + </row> + <row> + <entry><literal>%P</literal></entry> + <entry>lower-case 'am' or 'pm' based on the given time</entry> + <entry>Example: <literal>am</literal> for 00:31, <literal>pm</literal> for 22:23</entry> + </row> + <row> + <entry><literal>%r</literal></entry> + <entry>Same as "%I:%M:%S %p"</entry> + <entry>Example: <literal>09:34:17 PM</literal> for 21:34:17</entry> + </row> + <row> + <entry><literal>%R</literal></entry> + <entry>Same as "%H:%I"</entry> + <entry>Example: <literal>00:35</literal> for 12:35 AM, <literal>16:44</literal> for 4:44 PM</entry> + </row> + <row> + <entry><literal>%S</literal></entry> + <entry>Two digit representation of the second</entry> + <entry><literal>00</literal> through <literal>59</literal></entry> + </row> + <row> + <entry><literal>%T</literal></entry> + <entry>Same as "%H:%M:%S"</entry> + <entry>Example: <literal>21:34:17</literal> for 09:34:17 PM</entry> + </row> + <row> + <entry><literal>%X</literal></entry> + <entry>Preferred time representation based on locale, without the date</entry> + <entry>Example: <literal>03:59:16</literal> or <literal>15:59:16</literal></entry> + </row> + <row> + <entry><literal>%z</literal></entry> + <entry>Either the time zone offset from UTC or the abbreviation (depends + on operating system)</entry> + <entry>Example: <literal>-0500</literal> or <literal>EST</literal> for Eastern Time</entry> + </row> + <row> + <entry><literal>%Z</literal></entry> + <entry>The time zone offset/abbreviation option NOT given by %z (depends + on operating system)</entry> + <entry>Example: <literal>-0500</literal> or <literal>EST</literal> for Eastern Time</entry> + </row> + <row> + <entry align="center"><emphasis>Time and Date Stamps</emphasis></entry> + <entry>---</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%c</literal></entry> + <entry>Preferred date and time stamp based on local</entry> + <entry>Example: <literal>Tue Feb 5 00:45:10 2009</literal> for + February 4, 2009 at 12:45:10 AM</entry> + </row> + <row> + <entry><literal>%D</literal></entry> + <entry>Same as "%m/%d/%y"</entry> + <entry>Example: <literal>02/05/09</literal> for February 5, 2009</entry> + </row> + <row> + <entry><literal>%F</literal></entry> + <entry>Same as "%y-%m-%d" (commonly used in database datestamps)</entry> + <entry>Example: <literal>2009-02-05</literal> for February 5, 2009</entry> + </row> + <row> + <entry><literal>%s</literal></entry> + <entry>Unix Epoch Time timestamp (same as the <function>time</function> + function)</entry> + <entry>Example: <literal>305815200</literal> for September 10, 1979 08:40:00 AM</entry> + </row> + <row> + <entry><literal>%x</literal></entry> + <entry>Preferred date representation based on locale, without the time</entry> + <entry>Example: <literal>02/05/09</literal> for February 5, 2009</entry> + </row> + <row> + <entry align="center"><emphasis>Miscellaneous</emphasis></entry> + <entry>---</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%n</literal></entry> + <entry>A newline character ("\n")</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%t</literal></entry> + <entry>A Tab character ("\t")</entry> + <entry>---</entry> + </row> + <row> + <entry><literal>%%</literal></entry> + <entry>A literal percentage character ("%")</entry> + <entry>---</entry> + </row> + </tbody> + </tgroup> + </table> </para> <para> Maximum length of this parameter is 1023 characters. </para> + <warning> + <simpara> + Contrary to ISO-9889:1999, Sun Solaris starts with Sunday as 1. + As a result, %u may not function as described in this manual. + </simpara> + </warning> </listitem> </varlistentry> @@ -270,10 +321,10 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - Returns a string formatted according to the given format string + Returns a string formatted according <parameter>format</parameter> using the given <parameter>timestamp</parameter> or the current local time if no timestamp is given. Month and weekday names and - other language dependent strings respect the current locale set + other language-dependent strings respect the current locale set with <function>setlocale</function>. </para> </refsect1> @@ -307,7 +358,7 @@ <refsect1 role="examples"> &reftitle.examples; <para> - This example works if you have the respective locales installed + This example will work if you have the respective locales installed in your system. <example> <title><function>strftime</function> locale examples</title>
« previous php.doc.cvs (#3149) next »