Error when manipulating the date 2008-11-02

Posted on 2008-11-18
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
    LVL 11

    Accepted Solution

    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


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

    Author Comment

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now