From:             nicollasrs at gmail dot com
Operating system: Windows XP Professional SP2
PHP version:      5.2.5
PHP Bug Type:     Date/time related
Bug description:  Bug in date generation with mktime and strtotime

Description:
------------
When i try convert date "Jan 15 2008, 19:28:09 CET" to unix timestamp and
convert again to date, php show incorrect date.

Reproduce code:
---------------
$Temp = "Jan 15 2008, 19:28:09 CET";
echo "Date: $Temp<br><br>";
echo "Trying strtotime: ".strtotime($Temp)."<br>";
echo "Date: ".date("d/m/Y - H:m:s", strtotime($Temp))."<br><br>";

function fixTime($Date) {
        $Date = str_replace(",", null, $Date);
        $Date = explode(" ", $Date);
        $DateTemp = strtotime($Date[0].$Date[1].$Date[2]);
        $Dia = date("d", $DateTemp); $Mes = date("m", $DateTemp); $Ano =
date("Y", $DateTemp);
        $Time = explode(":", $Date[3]);
        $Hora = $Time[0]; $Minuto = $Time[1]; $Segundo = $Time[2];
        $CEST = $Date[4];
        echo "mktime($Hora, $Minuto, $Segundo, $Mes, $Dia, $Ano)<br><br>";
        return mktime($Hora, $Minuto, $Segundo, $Mes, $Dia, $Ano);
}

$Temp = fixTime($Temp);
echo "Trying mktime: $Temp<br>";
echo "Date: ".date("d/m/Y - H:m:s", $Temp)."<br>";

Expected result:
----------------
Date: Jan 15 2008, 19:28:09 CET

Trying strtotime: ??????????
Date: 15/01/2008 - 19:28:09

mktime(19, 28, 09, 01, 15, 2008)

Trying mktime: ?????????
Date: 15/01/2008 - 19:28:09

Actual result:
--------------
Date: Jan 15 2008, 19:28:09 CET

Trying strtotime: 1200421689
Date: 15/01/2008 - 16:01:09

mktime(19, 28, 09, 01, 15, 2008)

Trying mktime: 1200432489
Date: 15/01/2008 - 19:01:09

-- 
Edit bug report at http://bugs.php.net/?id=43858&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43858&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43858&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43858&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43858&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43858&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43858&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43858&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43858&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43858&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43858&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43858&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43858&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43858&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43858&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43858&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43858&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43858&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43858&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43858&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43858&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43858&r=mysqlcfg

Reply via email to