php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47735 strtotime "weekday" keyword yields false results on weekends
Submitted: 2009-03-20 17:17 UTC Modified: 2009-09-26 01:00 UTC
Votes:7
Avg. Score:4.0 ± 0.9
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:1 (16.7%)
From: jmccombs at bloosky dot com Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.2.9 OS: Windows XP
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: jmccombs at bloosky dot com
New email:
PHP Version: OS:

 

 [2009-03-20 17:17 UTC] jmccombs at bloosky dot com
Description:
------------
In strtotime, using the keyword "weekday" to calculate a date yields false results when:
  - starting from a weekend date (including Friday)
  - AND end date lands on a weekend



Reproduce code:
---------------
<?php
     echo date("Y-m-d", strtotime("2009-03-20 +5 weekday"))."\n";
     //EXPECT: 2009-03-27.  RETURNS: 2009-03-29


     echo date("l", strtotime("friday +5 weekday"))."\n";
     //EXPECT: "Friday".  RETURNS: "Sunday"


     ## Works fine as long as start date is not a weekend...
     echo date("l", strtotime("thursday +6 weekday"))."\n";
     //EXPECT: "Friday".  RETURNS: "Friday"

     ## ...OR end date does not land on weekend:
     echo date("l", strtotime("friday +4 weekday"))."\n";
     //EXPECT: "Thursday".  RETURNS: "Thursday"
?> 

Expected result:
----------------
2009-03-27
Friday
Friday
Thursday

Actual result:
--------------
2009-03-29
Sunday
Friday
Thursday

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-18 19:03 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-09-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-11-09 15:39 UTC] inigoesdr+nospam at gmail dot com
This appears to be fixed in PHP 5.2.11
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 18:01:28 2024 UTC