|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69786 strtotime troubles when subtracting days
Submitted: 2015-06-09 13:57 UTC Modified: 2015-06-10 13:36 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: s dot rotondo90 at gmail dot com Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: 5.5.25 OS: Windows Server 2012 R2 Standard
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-06-09 13:57 UTC] s dot rotondo90 at gmail dot com
When subtracting days from the next day of the week and today is the same day of the week, strtotime use the current date instead.  

Test script:
// Today is 09/06/2015

echo date('d/m/Y', strtotime('next tue'));
echo date('d/m/Y', strtotime('next tue -1 day'));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-10 12:04 UTC]
Hm, I'm not sure if that is supposed to work. Apparently 'next tue'
is simply ignored and only '-1 day' is calculated.

Anyhow, do you really mean 'next tue -1 day' instead of 'next
mon'? Both have, of course, different results on Mondays.
 [2015-06-10 13:10 UTC] s dot rotondo90 at gmail dot com
I used Tuesday because i saw that this happen when using the same day for the next week.

For example today is Wednesday and if i try this:
echo date('d/m/Y', strtotime('next wed -1 day'));

the output will be: 09/06/2015
The "next wed" seems to be ignored as you said.

But, if i try to do the opposite operation:
echo date('d/m/Y', strtotime('next wed +1 day'));

the output will be: 18/06/2015
This time "next wed" worked well.
 [2015-06-10 13:36 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC