php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14676 bug: strtotime incorrect GMT conversion from date('r')
Submitted: 2001-12-23 17:02 UTC Modified: 2001-12-23 17:03 UTC
From: irm at in3activa dot net Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.1.0 OS: win
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: irm at in3activa dot net
New email:
PHP Version: OS:

 

 [2001-12-23 17:02 UTC] irm at in3activa dot net
Suppose your machine is GMT+1. 

When date('r') returns also GMT+1, strtotime()
shows a bug.

<?
$stamp= "Thu, 20 Dec 2001 09:49:52 +0100";
$stamp= strtotime($stamp);
echo "$stamp = " . date("r", $stamp);                 
//Shows: 1008481792 = Sun, 16 Dec 2001 06:49:52 +0100
?>

To give you an idea of the solution, I use the 
following code to get correct results:

<?
$stamp= "20 Dec 2001 09:49:52 +0100";
// beg patch-line 
if( strpos($stamp, date('O')))$stamp= substr($stamp,0,-6);
// end patch-line 
$stamp= strtotime($stamp);
echo "$stamp = " . date("r", $stamp);                 
//Shows: 1008838192 = Thu, 20 Dec 2001 09:49:52 +0100
?>

There is no problem when GMT date('r') 
is different from GMT as returned by date('O')

Regards, IRMaturana

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-23 17:03 UTC] derick@php.net
Already fixed, and this will be in the maintenance release 4.1.1, which is due in a few days.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 17:01:31 2024 UTC