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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC