php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64181 Incorrect value for DateTime "this week" start
Submitted: 2013-02-09 23:50 UTC Modified: 2016-08-07 09:29 UTC
Votes:19
Avg. Score:4.5 ± 1.0
Reproduced:18 of 18 (100.0%)
Same Version:6 (33.3%)
Same OS:12 (66.7%)
From: grey2k at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.3.21 OS: Linux and Windows
Private report: No CVE-ID: None
 [2013-02-09 23:50 UTC] grey2k at gmail dot com
Description:
------------
the problem is:

in sunday code output date for Monday next week

$date = new DateTime();
$date->setTimezone(new DateTimeZone('Europe/Moscow'));
$date->setTimestamp(strtotime('Monday this week'));

echo $date->format("d.m.Y"); 

but in other days (except Sunday) its return correct value of Monday.

I ever set locale manualy , which has a monday - the first day of week, but PHP "think" the Sunday is still firs day. is it bug ?? or i do some wrong ?

for check this you need to set you local time in any Sunday.

Test script:
---------------
$date = new DateTime();
$date->setTimezone(new DateTimeZone('Europe/Moscow'));
$date->setTimestamp(strtotime('Monday this week'));

echo $date->format("d.m.Y");

Expected result:
----------------
The value on this week Monday.

for example in Sunday of 10.02.2012 i expect to see 04.02.2012. 



Actual result:
--------------
if i test this code at Sunday 10.02.2012 - actual result is 11.02.2012 

- it's wrong because this is a next week

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-11 17:34 UTC] timakeeling at gmail dot com
I think that this is a duplicate of bug #63740.
https://bugs.php.net/bug.php?id=63740
 [2016-08-07 09:29 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2016-08-07 09:29 UTC] cmb@php.net
> I think that this is a duplicate of bug #63740.

Indeed, it is.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 12 14:01:28 2024 UTC