[PHP-DOC] cvs: phpdoc /en/reference/datetime/functions strftime.xml From: Sara Golemon (php <email protected>)
Date: 12/31/02

pollita Tue Dec 31 14:18:14 2002 EDT

  Modified files:
    /phpdoc/en/reference/datetime/functions strftime.xml
  Log:
  Per multiple "bug" reports of misunderstanding use of %G and %V, added example showing week numbers for 2002/2003 (week forward) and 2004/2005 (week backward).
  
  
Index: phpdoc/en/reference/datetime/functions/strftime.xml
diff -u phpdoc/en/reference/datetime/functions/strftime.xml:1.4 phpdoc/en/reference/datetime/functions/strftime.xml:1.5
--- phpdoc/en/reference/datetime/functions/strftime.xml:1.4 Tue Nov 26 15:41:08 2002
+++ phpdoc/en/reference/datetime/functions/strftime.xml Tue Dec 31 14:18:14 2002
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
 <!-- splitted from ./en/functions/datetime.xml, last change in rev 1.2 -->
   <refentry id="function.strftime">
    <refnamediv>
@@ -242,7 +242,7 @@
       </para>
      </note>
      <example>
- <title><function>strftime</function> example</title>
+ <title><function>strftime</function> locale examples</title>
       <programlisting role="php">
 <![CDATA[
 setlocale (LC_TIME, "C");
@@ -258,6 +258,66 @@
      </example>
      This example works if you have the respective locales installed
      in your system.
+ <note>
+ <simpara>
+ %G and %V, which are based on ISO 8601:1988 week numbers can
+ give unexpected (albiet correct) results if the numbering system
+ is not thoroughly understood. See %V above and example below.
+ </simpara>
+ </note>
+ <example>
+ <title>ISO 8601:1988 week number example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* December 2002 / January 2003
+ISOWk M Tu W Thu F Sa Su
+----- ----------------------------
+51 16 17 18 19 20 21 22
+52 23 24 25 26 27 28 29
+1 30 31 1 2 3 4 5
+2 6 7 8 9 10 11 12
+3 13 14 15 16 17 18 19 */
+
+// Outputs: 12/28/2002 - %V,%G,%Y = 52,2002,2002
+print "12/28/2002 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/28/2002")) . "\n";
+
+// Outputs: 12/30/2002 - %V,%G,%Y = 1,2003,2002
+print "12/30/2002 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/30/2002")) . "\n";
+
+// Outputs: 1/3/2003 - %V,%G,%Y = 1,2003,2003
+print "1/3/2003 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/3/2003")) . "\n";
+
+// Outputs: 1/10/2003 - %V,%G,%Y = 2,2003,2003
+print "1/10/2003 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/10/2003")) . "\n";
+
+
+
+/* December 2004 / January 2005
+ISOWk M Tu W Thu F Sa Su
+----- ----------------------------
+51 13 14 15 16 17 18 19
+52 20 21 22 23 24 25 26
+53 27 28 29 30 31 1 2
+1 3 4 5 6 7 8 9
+2 10 11 12 13 14 15 16 */
+
+// Outputs: 12/23/2004 - %V,%G,%Y = 52,2004,2004
+print "12/23/2004 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/23/2004")) . "\n";
+
+// Outputs: 12/31/2004 - %V,%G,%Y = 53,2004,2004
+print "12/31/2004 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("12/31/2004")) . "\n";
+
+// Outputs: 1/2/2005 - %V,%G,%Y = 53,2004,2005
+print "1/2/2005 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/2/2005")) . "\n";
+
+// Outputs: 1/3/2005 - %V,%G,%Y = 1,2005,2005
+print "1/3/2005 - %V,%G,%Y = " . strftime("%V,%G,%Y",strtotime("1/3/2005")) . "\n";
+
+?>
+]]>
+ </programlisting>
+ </example>
     </para>
     <para>
      See also <function>setlocale</function> and

-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php