php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69176 strtotime: support "first/last of" with weeks
Submitted: 2015-03-03 19:05 UTC Modified: 2015-05-28 11:30 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: cpuidle at gmx dot de Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.6.6 OS: any
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cpuidle at gmx dot de
New email:
PHP Version: OS:

 

 [2015-03-03 19:05 UTC] cpuidle at gmx dot de
Description:
------------
Both give the same results- Sunday 00:00

strtotime("first day of last week 00:00")
strtotime("first day of this week 00:00")

While Monday is a perfect workaround for "first day" it should work according to http://php.net/manual/de/datetime.formats.relative.php

Also, when exchanging week with month, it works like a charm.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-03 19:59 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2015-03-03 19:59 UTC] ab@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

"first day of" is only documented to only work with months.

Thanks.
 [2015-03-04 08:04 UTC] cpuidle at gmx dot de
> "first day of" is only documented to only work with months.

Not explicitly. In fact, docs say:

> This phrase is best used together with a month name following it.

It would actually be in line to make this work with year as well as week. Feel free to treat this as an enhancement request.
 [2015-03-04 19:28 UTC] aharvey@php.net
-Summary: strtotime if wrong with first/last day of week +Summary: strtotime: support "first/last of" with weeks -Status: Not a bug +Status: Open -Type: Bug +Type: Feature/Change Request -Package: Strings related +Package: Date/time related
 [2015-03-15 18:03 UTC] ab@php.net
-Operating System: Windows +Operating System: any
 [2015-05-28 09:56 UTC] arjen at react dot com
Use 'dayname [this|last] week midnight'.

See http://3v4l.org/MeDGO
 [2015-05-28 11:30 UTC] cpuidle at gmx dot de
Nice suggestion. Thats actually how I finally solved it. You link gives strange results though for 5.2.0 - 5.2.17 versions and newer:

string(25) "2015-05-28T00:00:00+02:00" string(25) "2015-06-01T00:00:00+02:00" string(25) "2015-05-28T00:00:00+02:00" string(25) "2015-05-25T00:00:00+02:00"

PHP 5.2 lives one week in the future or seems to have a different notion of week start.

But well, those are old anyway...
 [2022-05-13 14:47 UTC] git@php.net
Automatic comment on behalf of derickr
Revision: https://github.com/php/doc-en/commit/d836dea93eeac2383cd4bd7dc09229a1e5652c58
Log: Fixed #69176: strtotime: support "first/last of" with weeks
 [2022-05-13 14:47 UTC] git@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC