php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51457 gmdate interpretation
Submitted: 2010-04-01 22:16 UTC Modified: 2010-04-02 04:46 UTC
From: mobile at bingeman dot org dot uk Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.3.2 OS: linux
Private report: No CVE-ID: None
 [2010-04-01 22:16 UTC] mobile at bingeman dot org dot uk
Description:
------------
Hi all 
I must be missing the plot, I have just noticed that when accessing date information from a MYSQL DB, which has been stored in the format yyyy-mm-dd, the date is being displayed incorrectly as of 29/03/2010. Any date displayed using gmdate from and including 29/03/2010 and upto 04/04/2010, possibly further, is being displayed as the stored date LESS 1 day.

Example 
DB table shows 2010-03-30

echo gmdate("d-m-Y", strtotime("$test1")); interpretates the same information as 29-03-2010.

Am I missing the point or is there something wrong?

Regards
Ross

Test script:
---------------
<?
$test26="2010-03-26";
$test27="2010-03-27";
$test28="2010-03-28";
$test29="2010-03-29";
$test30="2010-03-30";
$test31="2010-03-31";
$test32="2010-04-01";
$test33="2010-04-02";
echo gmdate("d-m-Y", strtotime("$test26")),"  = $test26<br>";
echo gmdate("d-m-Y", strtotime("$test27")),"  = $test27<br>";
echo gmdate("d-m-Y", strtotime("$test28")),"  = $test28<br>";
echo gmdate("d-m-Y", strtotime("$test29")),"  = $test29<br>";
echo gmdate("d-m-Y", strtotime("$test30")),"  = $test30<br>";
echo gmdate("d-m-Y", strtotime("$test31")),"  = $test31<br>";
echo gmdate("d-m-Y", strtotime("$test32")),"  = $test32<br>";
echo gmdate("d-m-Y", strtotime("$test33")),"  = $test33<br>";
?>

Expected result:
----------------
26-03-2010 = 2010-03-26
27-03-2010 = 2010-03-27
28-03-2010 = 2010-03-28
29-03-2010 = 2010-03-29
30-03-2010 = 2010-03-30
31-03-2010 = 2010-03-31
01-03-2010 = 2010-04-01
02-04-2010 = 2010-04-02


Actual result:
--------------
26-03-2010 = 2010-03-26
27-03-2010 = 2010-03-27
28-03-2010 = 2010-03-28
28-03-2010 = 2010-03-29
29-03-2010 = 2010-03-30
30-03-2010 = 2010-03-31
31-03-2010 = 2010-04-01
01-04-2010 = 2010-04-02


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-02 04:46 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-04-02 04:46 UTC] aharvey@php.net
Since you're in the UK, and your computer/server is hence probably set to Europe/London as a time zone, this is likely due to daylight saving time.

For example, with 2010-04-01, strtotime() will be returning 12:00 am on the 1st of April in your local time zone, but as the UK is now GMT+1, gmdate() interprets that as being 11:00 pm on the previous day (which it is in GMT), hence you get the result of 31-03-2010.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 12 09:01:33 2024 UTC