php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43208 Calculation not taking place
Submitted: 2007-11-06 19:09 UTC Modified: 2007-11-11 14:54 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: joel at digitalparadise dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.4 OS: Windows 2000 Server
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: joel at digitalparadise dot net
New email:
PHP Version: OS:

 

 [2007-11-06 19:09 UTC] joel at digitalparadise dot net
Description:
------------
This code is part of a larger while loop which stops when "$dayloop == false".

This page is a report of employee clock-in and clock-out times.  It shows the employee, followed by each day that the report includes, and their times.

This code works in some circumstances, but most of the time, the 3rd line simply does not execute, or rather the value is never updated - thus resulting in an endless loop (because $dayloop stays true).

It used to work perfectly (for over 6 months...) on several versions of PHP, so I do not believe this to be something version-related.

Reproduce code:
---------------
At this point, $thisday would be a date in the format "YYYY-mm-dd".

$timestamp = strtotime($thisday);
$timestamp = $timestamp + (60 * 60 * 24);  <-- this line does not work
if ($timestamp > strtotime($enddate)) {
   $dayloop = false;
}
$thisday = date("Y-m-d", $timestamp);      <-- creates the above value

Expected result:
----------------
$timestamp = $timestamp + (60 * 60 * 24) 

I expect the value of $timestamp to increase by 86400.

Actual result:
--------------
Sometimes the code works for a few cycles, but eventually it will stop incrementing the value of $timestamp and the script will time out.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-11 14:54 UTC] derick@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: Fri Jul 19 10:01:29 2024 UTC