Bug #75524 [Opn->Nab]: last monday this week working wrong
| From: | danack@php.net | Date: | Tue, 14 Nov 2017 17:04:28 +0000 |
| Subject: | Bug #75524 [Opn->Nab]: last monday this week working wrong | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-212582@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75524&edit=1
ID: 75524
Updated by: danack@php.net
Reported by: padre dot cedano at gmail dot com
Summary: last monday this week working wrong
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
PHP Version: 7.0.25
Block user comment: N
Private report: N
New Comment:
I really doubt this is a bug.
Doing 'monday this week' is not only clearer english, but also gives you the result you
want, I think.
https://3v4l.org/UYsNE
'last monday this week' - means from the start of this week, find the previous monday. Not
find the monday of this week.
Previous Comments:
------------------------------------------------------------------------
[2017-11-14 16:45:21] padre dot cedano at gmail dot com
Previuos package error
------------------------------------------------------------------------
[2017-11-14 16:44:07] padre dot cedano at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/datetime.modify
---
If i try this today, 2o17-11-14:
modify('last monday this week')
the result is:
06/11/2017
But last monday this week was:
13/11/2017
Test script:
---------------
<?php
function getLastDayofWeek ($strDia){
$date=new DateTime('now');
$strCriterio='last '.$strDia.' this week';
$date->modify($strCriterio);
echo $strCriterio.": ".$date->format('d/m/Y').PHP_EOL;
}
/*Pruebas*/
getLastDayofWeek('monday');
getLastDayofWeek('saturday');
getLastDayofWeek('sunday');
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75524&edit=1