|  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 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.
Block user comment
Status: Assign to:
Bug Type:
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


Add a Patch

Pull Requests

Add a Pull Request


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

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Jun 05 23:03:36 2023 UTC