Bug #52340 [Bgs]: strtotime conversion error
| From: | salathe@php.net | Date: | Thu, 15 Jul 2010 09:21:59 +0000 |
| Subject: | Bug #52340 [Bgs]: strtotime conversion error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-152427@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52340&edit=1
ID: 52340
Updated by: salathe@php.net
Reported by: andrea dot romagnoli at getlocal dot it
Summary: strtotime conversion error
Status: Bogus
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 5.3.2
New Comment:
The following will return 23 hours. If the result does not equate to
your own
"day by day" values please provide a similar short script to demonstrate
the
problem.
<?php
date_default_timezone_set('Europe/London');
$diff = strtotime('28 March 2010 06:00:00') - strtotime('27 March 2010
06:00:00');
var_dump($diff / 3600); // difference in hours (23)
?>
Previous Comments:
------------------------------------------------------------------------
[2010-07-15 11:07:20] andrea dot romagnoli at getlocal dot it
Yes, but if I check the difference day by day from 22 march to 29 march
is ever of 24H, why the daylight saving is show to me only if I subtract
a week?
------------------------------------------------------------------------
[2010-07-15 10:58:18] salathe@php.net
The actual number of seconds between those two date/times is expected.
This is
because it crosses a Daylight Savings boundary (at
2010-03-28T01:00:00+0000).
Since the clocks went forward by an hour at that time, the number of
seconds
between the dates reflects that resulting in a "missing" hour.
For more information see
http://en.wikipedia.org/wiki/Daylight_saving_time
------------------------------------------------------------------------
[2010-07-15 01:50:18] andrea dot romagnoli at getlocal dot it
Description:
------------
The result of subtraction between result of strtotime("Monday 29 March
2010 06:00:00") and the result of strtotime("Monday 22 March 2010
06:00:00") is not a week, but instead is a week less 2,5 minutes...
Infact a week are 604800 seconds but the result of this subtraction is
601200.
I tried to subtract day per day in the interval and all subtractions are
correct and results every time 86400 seconds.
Test script:
---------------
<?php
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set ('Europe/London');
$dates = array("Monday 15 March 2010 06:00:00", "Monday 22 March 2010
06:00:00",
"Monday 29 March 2010 06:00:00", "Monday 05 April 2010 06:00:00",
"Monday 12 April 2010 06:00:00", "Monday 19 April 2010 06:00:00");
var_dump($dates);
$datesInt = array();
foreach($dates as $date)
$datesInt[] = strtotime($date);
$lastDate = $datesInt[0];
for($i = 1; $i < count($datesInt); $i++){
$tmp = $datesInt[$i]-$lastDate;
var_dump($tmp);
$lastDate = $datesInt[$i];
}
?>
Expected result:
----------------
I think that all subtractions should be return 604800 seconds.
Actual result:
--------------
Actually one of subtractions return 601200 instead of 604800 seconds.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52340&edit=1