ID:               48698
 Updated by:       scott...@php.net
 Reported By:      hlegius at gmail dot com
-Status:           Closed
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Linux
 PHP Version:      5.2.10
 New Comment:

Not a bug -> Bogus


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

[2009-06-26 11:47:41] hlegius at gmail dot com

was my fault !

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

[2009-06-26 10:47:39] hlegius at gmail dot com

Description:
------------
I expected the last day of given timestamp, but when mktime is the
second argument of strtotime this do not happens. So, I need save
mktime's result in a variable to use it later in strtotime

Reproduce code:
---------------
<?php
// FAIL !
        $timestamp = time();

        for ($i = 0; $i<10; $i++) {
                $timestamp = strtotime('yesterday', mktime(0,0,0, (date('n',
$timestamp) + 1), 1, date('Y')));
                
                var_dump(date('d/m/Y', $timestamp));
        }
?>

<?php
// It's works !
        $timestamp = time();

        for ($i = 0; $i<10; $i++) {
                $timestamp = mktime(0,0,0, (date('n', $timestamp) + 1), 1,
date('Y'));
                
                var_dump(date('d/m/Y', strtotime('yesterday', $timestamp))); // 
here,
we have a $timestamp
        }
?>

Expected result:
----------------
string '30/06/2009' (length=10)
string '31/07/2009' (length=10)
string '31/08/2009' (length=10)
string '30/09/2009' (length=10)
string '31/10/2009' (length=10)
string '30/11/2009' (length=10)
string '31/12/2009' (length=10)
string '31/01/2009' (length=10)
string '28/02/2009' (length=10)
string '31/03/2009' (length=10)

Actual result:
--------------
Output of first Code:

string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)
string '30/06/2009' (length=10)


Output of second code:

string '30/06/2009' (length=10)
string '31/07/2009' (length=10)
string '31/08/2009' (length=10)
string '30/09/2009' (length=10)
string '31/10/2009' (length=10)
string '30/11/2009' (length=10)
string '31/12/2009' (length=10)
string '31/01/2009' (length=10)
string '28/02/2009' (length=10)
string '31/03/2009' (length=10)



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


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

Reply via email to