ID:               21212
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: linux
 PHP Version:      4.2.3
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Please note the manual page:
http://www.php.net/manual/en/function.strftime.php

----------------------------
%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.


----------------------------

A reminder about ISO week numbers.  They begin on mondays, end on
sundays, and are considered a part of the year in which the majority of
their days fall.

12/31/2001 falls on a monday, it's ISO week ends on Sunday 1/6/2002,
(six days fall in 2002, one falls in 2001) ergo %G for that date
returns "2002".  

This is expected behavior for %G.  Try using %Y instead. 


Previous Comments:
------------------------------------------------------------------------

[2002-12-30 04:04:54] [EMAIL PROTECTED]

-

------------------------------------------------------------------------

[2002-12-27 08:22:26] [EMAIL PROTECTED]

/* function strftime produce wrong result with a timestamp close to the
end of
   Year,the four digit year value is sometimes 1 year after (see
"30/12/2002")
   and sometimes 1 year before (see "01/01/2005") the good one.
   hope this help
*/


$dateTab=array();
$dateTab[0]  = "Dec 29 2001";
$dateTab[1]  = "Dec 30 2001";
$dateTab[2]  = "Dec 31 2001"; wrong output with strftime
$dateTab[3]  = "Jan 01 2002";
$dateTab[4]  = "Dec 29 2002";
$dateTab[5]  = "Dec 30 2002"; wrong output with strftime
$dateTab[6]  = "Dec 31 2002"; wrong output with strftime
$dateTab[7]  = "Jan 01 2003";
$dateTab[8]  = "Dec 28 2003"; 
$dateTab[9]  = "Dec 29 2003"; wrong output with strftime
$dateTab[10] = "Dec 30 2003"; wrong output with strftime
$dateTab[11] = "Dec 31 2003"; wrong output with strftime
$dateTab[12] = "Jan 01 2004";
$dateTab[13] = "Dec 28 2004";
$dateTab[14] = "Dec 29 2004";
$dateTab[15] = "Dec 30 2004";
$dateTab[16] = "Dec 31 2004";
$dateTab[17] = "Jan 01 2005"; wrong output with strftime
$dateTab[18] = "Jan 02 2005"; wrong output with strftime
$dateTab[19] = "Jan 03 2005";
$dateTab[20] = "Jan 04 2005";
$dateTab[21] = "Jan 05 2005";

foreach($dateTab as $currentDate) {
    if (($timestamp = strtotime($currentDate)) === -1)
    {
        echo "The string ($currentDate) is bogus";
    } 
    else
    {
         $result[0] =  date('d/m/Y',$timestamp);
         $result[1] = strftime("%d/%m/%G",$timestamp);
        
         if($result[1] == $result[0]) {
            echo "$currentDate == $result[0] == $result[1]<br>"; 
         }
         else
         {
            echo "$currentDate == $result[0] != <font
color=red>$result[1]</font><br>"; 
         }
    }         
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=21212&edit=1

Reply via email to