ID:               43188
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ebrueggeman at gmail dot com
-Status:           Assigned
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Windows
 PHP Version:      5.2.4
 Assigned To:      derick
 New Comment:

This is correct behavior.

In the first example you add 5 times 24 hours, but in the 2nd one, you
add 5 days. There is a subtle difference here because Sunday November
4th, 2007 actually has *25* hours.

You can see this in action if you add "H:i:s T" to your formatting
strings:

<?php
date_default_timezone_set ("America/New_York");

$receiptStamp=mktime(0, 0, 0, 10, 31, 2007);
$modStamp= $receiptStamp + (5 * 24 * 60 * 60);  /* Addition of 5 days
of time */
echo date('m/d/Y H:i:s T', $modStamp) . "\n";
/* prints 11/04/2007 */

$dateObject=new DateTime("10/31/2007");
$dateObject->modify("+5 day");
echo date_format( $dateObject, 'm/d/Y H:i:s T' ). "\n";

/* prints 11/05/2007 */

/*After the old daylight savings crossover week*/

$dateObject=new DateTime("11/7/2007");
$dateObject->modify("+5 day");
echo date_format( $dateObject, 'm/d/Y H:i:s T' ). "\n";

/* prints 11/12/2007 */

$receiptStamp=mktime(0, 0, 0, 11, 7, 2007);
$modStamp= $receiptStamp + (5 * 24 * 60 * 60);  /* Addition of 5 days
of time */
echo date('m/d/Y H:i:s T', $modStamp). "\n";
?>

outputs:
11/05/2007 23:00:00 EST
11/05/2007 00:00:00 EST
11/12/2007 00:00:00 EST
11/12/2007 00:00:00 EST





Previous Comments:
------------------------------------------------------------------------

[2007-11-04 21:51:47] ebrueggeman at gmail dot com

Description:
------------
The date() function is not accurately displaying output expected of
dates during the 1 week long time before daylight savings time, likely
because of the change in the start of daylight savings time from the
year prior.

Reproduce code:
---------------
date_default_timezone_set ("America/New_York");
 
$receiptStamp=mktime(0, 0, 0, 10, 31, 2007);
$modStamp= $receiptStamp + (5 * 24 * 60 * 60);  /* Addition of 5 days
of time */
echo date('m/d/Y', $modStamp) . '<br>';
/*
prints 11/04/2007
*/
 
$dateObject=new DateTime("10/31/2007");
$dateObject->modify("+5 day");
echo date_format( $dateObject, 'm/d/Y' ). '<br>';
 
/*
prints 11/05/2007
*/
 
 
/*After the old daylight savings crossover week*/
 
$dateObject=new DateTime("11/7/2007");
$dateObject->modify("+5 day");
echo date_format( $dateObject, 'm/d/Y' ). '<br>';
 
/*
prints 11/12/2007
*/
 
$receiptStamp=mktime(0, 0, 0, 11, 7, 2007);
$modStamp= $receiptStamp + (5 * 24 * 60 * 60);  /* Addition of 5 days
of time */
echo date('m/d/Y', $modStamp). '<br>';

Expected result:
----------------
11/05/2007
11/05/2007
11/12/2007
11/12/2007

Actual result:
--------------
11/04/2007
11/05/2007
11/12/2007
11/12/2007


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43188&edit=1

Reply via email to