php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43858 Bug in date generation with mktime and strtotime
Submitted: 2008-01-15 20:01 UTC Modified: 2008-01-15 20:03 UTC
From: nicollasrs at gmail dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.2.5 OS: Windows XP Professional SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nicollasrs at gmail dot com
New email:
PHP Version: OS:

 

 [2008-01-15 20:01 UTC] nicollasrs at gmail dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-15 20:03 UTC] nicollasrs at gmail dot com
sorry... my bad
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Sep 24 11:01:25 2018 UTC