From: hazen at edsbits dot com Operating system: Red Hat Linux PHP version: 4.3.3 PHP Bug Type: Date/time related Bug description: strtotime() returns incorrect date (near daylight saving time change)
Description: ------------ I have code which uses human readable text to generate dates for use in a task management program which stores due dates in a MySQL database. I have been using the strtotime() function for some months with no problem. Now that it is near a change in daylight savings time, I'm finding some odd behavior. It is currently Friday October 24, 2003. When I enter "tuesday", the function returns 10-27-2003, not 10-28-2003 as it should. For a sanity check, I also entered "today + 4 days" which correctly returned 10-28-2003. If I enter "Saturday" or "Sunday", it correctly returns 10-25-2003 and 10-26-2003 respectively. Anything after Sunday is off by one day. Reproduce code: --------------- <?php $date_in = $_POST['date_in']; $date_out = date("Y-m-d", strtotime($date_in)); PRINT<<<END <H3>strtotime( ) tester</H3> <PRE> Input: $date_in Output: $date_out </PRE> <FORM ACTION="datetest.phtml" METHOD="post"> <INPUT TYPE="Text" SIZE="20" NAME="date_in" VALUE="$date_in"><BR> <INPUT TYPE="Submit" VALUE="Test Date"> </FORM> END; ?> Expected result: ---------------- That it returns the correct calendar date Actual result: -------------- It returns one day off, as explained in the description above. I also tested this bug on a second machine running PHP 4.3.2 with the same result. -- Edit bug report at http://bugs.php.net/?id=25981&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25981&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25981&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=25981&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=25981&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=25981&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=25981&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=25981&r=support Expected behavior: http://bugs.php.net/fix.php?id=25981&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=25981&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=25981&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=25981&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25981&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=25981&r=dst IIS Stability: http://bugs.php.net/fix.php?id=25981&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=25981&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=25981&r=float