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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Fri Dec 27 07:01:28 2024 UTC