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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC