php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40804 strtotime returning bad dates (last <day>)
Submitted: 2007-03-14 16:52 UTC Modified: 2007-03-14 16:54 UTC
From: zirephoenix at rogers dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.4.6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zirephoenix at rogers dot com
New email:
PHP Version: OS:

 

 [2007-03-14 16:52 UTC] zirephoenix at rogers dot com
Description:
------------
My hosting told me to post the bug here instead of asking them to figure it out.  They recently upgraded to 4.4.6 and the strtotime function started returning bad dates for some of the "last <day>" strings.

The code below should show a continuous list of dates, but it doesn't.  It seems to break from last week of today to last sunday.

Reproduce code:
---------------
<html>
<body>

<?php
echo date("F d, Y", strtotime("last sunday")) . "<br>\n";
echo date("F d, Y", strtotime("last monday")) . "<br>\n";
echo date("F d, Y", strtotime("last tuesday")) . "<br>\n";
echo date("F d, Y", strtotime("last wednesday")) . "<br>\n";
echo date("F d, Y", strtotime("last thursday")) . "<br>\n";
echo date("F d, Y", strtotime("last friday")) . "<br>\n";
echo date("F d, Y", strtotime("last saturday")) . "<br>\n";
?>

</body>
</html>


Expected result:
----------------
March 11, 2007
March 12, 2007
March 13, 2007
March 07, 2007
March 08, 2007
March 09, 2007
March 10, 2007

Actual result:
--------------
March 10, 2007
March 12, 2007
March 13, 2007
March 06, 2007
March 07, 2007
March 08, 2007
March 09, 2007

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-14 16:54 UTC] derick@php.net
We are happy to tell you that you just discovered Daylight Savings
Time. For more information see:
http://webexhibits.org/daylightsaving/b.html
Instead of using mktime/date consider using gmmktime and gmdate which do
not suffer from DST.

Add the time to your example code to show what really happens.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 03 17:01:33 2024 UTC