Edit report at https://bugs.php.net/bug.php?id=64448&edit=1

 ID:                 64448
 User updated by:    xojins at gmail dot com
 Reported by:        xojins at gmail dot com
 Summary:            DATE Day of Week bug for 3-10-2013
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   RedHat EL5
 PHP Version:        5.3.23
 Block user comment: N
 Private report:     N

 New Comment:

I have tested this with the following timezones:
America/New_York
US/Pacific

Also tested with PHP 5.4.12 and 5.5.0 alpha 5. All exhibit the same symptom.


Previous Comments:
------------------------------------------------------------------------
[2013-03-18 20:56:10] ahar...@php.net

Which time zone is PHP configured to operate in (ie what do you get if you echo 
date_default_timezone_get())?

------------------------------------------------------------------------
[2013-03-18 20:47:40] xojins at gmail dot com

Description:
------------
When using the DATE function and returning the day of the week (lowercase L 
format) returns the wrong day of the week for 3/10/2013.

The example provided shows subtracting 86400 seconds from 
strtotime('03/11/2013') 
to return 1362888000 seconds. When passed to DATE, it returns Saturday. This is 
wrong and should be Sunday.

You need to add 3600 to any value to calculate 3/10/13 correctly.


Test script:
---------------
$d1 = date('l', strtotime('03/12/2013')-(60*60*24));  //date('l', 1363060800 - 
86400) = date('l', 1362974400) = Monday

$d2 =date('l', strtotime('03/11/2013')-(60*60*24));  //date('l', 1362974400 - 
86400) = date('l', 1362888000) = Saturday != date('m-d-y', 1362888000)

$d3 =date('l', strtotime('03/10/2013')-(60*60*24));  //date('l', 1362891600 - 
86400) = date('l', 1362805200) = Saturday 

echo $d1 . '<br>';
echo $d2 . '<br>';
echo $d3 . '<br>';

Expected result:
----------------
Monday
Sunday
Saturday

Actual result:
--------------
Monday
Saturday
Saturday


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



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

Reply via email to