php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63392 DateTime::modify() start of week inconsistency
Submitted: 2012-10-30 02:26 UTC Modified: 2016-08-07 09:32 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: chris at cmbuckley dot co dot uk Assigned: derick (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.4Git-2012-10-30 (snap) OS:
Private report: No CVE-ID: None
 [2012-10-30 02:26 UTC] chris at cmbuckley dot co dot uk
Description:
------------
Calling $dt->modify("Monday this week") for all dates 13–19 May 2012 (Sun–Sat) 
result in the same date (2012-05-14), suggesting that "this week" runs Sun–Sat. 
However, calling $dt->modify("Sunday this week") gives the "next" Sunday (2012-
05-20) for the same range.

On a related note, the documentation on relative date formats is lacking on the 
behaviour of this and strtotime when used with locales; one might expect the 
start of the week to be interpreted from LC_TIME.

Test script:
---------------
<?php

$dt = new DateTime("2012-05-13");
$dt->modify("Sunday this week");
var_dump($dt->format('r'));

Expected result:
----------------
string(31) "Sun, 13 May 2012 00:00:00 +0000"

Actual result:
--------------
string(31) "Sun, 20 May 2012 00:00:00 +0000"

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-24 11:17 UTC] pajoye@php.net
-Assigned To: +Assigned To: derick
 [2012-11-24 11:17 UTC] pajoye@php.net
See also PR https://github.com/php/php-src/pull/224
 [2016-08-07 09:32 UTC] cmb@php.net
-Status: Assigned +Status: Duplicate
 [2016-08-07 09:32 UTC] cmb@php.net
This is actually a duplicate of bug #63740, which has been fixed
as of PHP 5.6.23 and 7.0.8, respectively (see
<https://3v4l.org/6uKQr>).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC