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 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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Tue May 24 00:03:50 2022 UTC