php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50631 strtotime() gives incorrect output for certain date
Submitted: 2010-01-02 06:04 UTC Modified: 2010-01-02 06:27 UTC
From: barlow at fhtsolutions dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.12 OS: Linux or XP
Private report: No CVE-ID: None
 [2010-01-02 06:04 UTC] barlow at fhtsolutions dot com
Description:
------------
strtotime() reports an incorrect value for a particular date: 2010-03-15

It seems to think that this day has 23 hours!

Reproduce code:
---------------
---
From manual page: function.strtotime#Description
---
<?php
$a = strtotime("2010-03-14");
$b = strtotime("2010-03-15");

echo "Number of hours difference: ".(($b-$a)/3600)."<br />";

// shows 23 !  WRONG!
// PHP Version 5.2.12
?>

Expected result:
----------------
Number of hours difference: 24

Actual result:
--------------
Number of hours difference: 23

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-02 06:27 UTC] rasmus@php.net
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
Instead of using mktime/date consider using gmmktime and gmdate which do
not suffer from DST.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 19:01:32 2024 UTC