|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-07-15 01:50 UTC] 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 19:00:02 2025 UTC |
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) ?>