php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25981 strtotime() returns incorrect date (near daylight saving time change)
Submitted: 2003-10-24 18:22 UTC Modified: 2003-10-28 16:28 UTC
From: hazen at edsbits dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.3 OS: Red Hat Linux
Private report: No CVE-ID: None
 [2003-10-24 18:22 UTC] hazen at edsbits dot com
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-28 16:28 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.

See bug #20382

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 00:01:33 2024 UTC