Error when manipulating the date 2008-11-02

Posted on 2008-11-18
Medium Priority
Last Modified: 2012-05-05
I'm coming across a very strange problem when  my script hits 2008-11-02 and I'm not sure why. What the script does is accept a start date and an end date and then loops through days between. It works perfectly as long as the date range doesn't include 2008-11-02. If it does, it will never get passed that date during the accumulation looping process. What am I missing? Any help would be most appreciated.
		$s = date("Y-m-d", strtotime($_POST['startDate']));
		$e = date("Y-m-d", strtotime($_POST['endDate']) + 86400);
		while($s != $e){
    	<th align="right"><?= date("Y-m-d", strtotime($s)); ?></th>
			$time = strtotime($s) + 86400;
			$s = date("Y-m-d", $time);
			if($count > 200){
				die("This catch is in here for the 11/02/2008 bug.");

Open in new window

Question by:brettfarris
  • 2
LVL 11

Accepted Solution

spoxox earned 2000 total points
ID: 22988903
Because Nov 2 the time changed.

You need to add another 3600 seconds to make up the shortfall for that day (only).
LVL 11

Expert Comment

ID: 22988913

      $time = strtotime($s) + 86400;
      if ($time == 1225684800) $time+= 3600; // might be a nicer way to do this!

Author Comment

ID: 22989429
Excellent, that definitely sent me in the right direction. Thanks for your assistance. Here's how I handled it:
$time = strtotime($s) + 86400;
// The following block handles time change.
if((string)date("Y-m-d", $time) == (string)date("Y-m-d", strtotime($s))){
  $time += 3600;

Open in new window


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question