Bug #78827 [Opn]: Wrong timestamp
| From: | cmb@php.net | Date: | Sat, 23 Nov 2019 09:08:26 +0000 |
| Subject: | Bug #78827 [Opn]: Wrong timestamp | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-223870@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78827&edit=1
ID: 78827
Updated by: cmb@php.net
Reported by: obreham at gmail dot com
Summary: Wrong timestamp
Status: Open
Type: Bug
Package: Date/time related
Operating System: Ubuntu 16.04.6 LTS
PHP Version: 7.3.11
Block user comment: N
Private report: N
New Comment:
Isn't that suppossed to be
Sunday last week instead of `last
Sunday`?
Previous Comments:
------------------------------------------------------------------------
[2019-11-17 21:22:48] obreham at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.strftime
---
When adding a time interval to 'last Sunday' on a Sunday, you get an incorrect timestamp
when interval is longer than a week. 'last Sunday' becomes 'this Sunday'.
Test script:
---------------
/* Example code was run on Sunday Nov 17, 2019 */
var_dump(
$saturday = strtotime('last Saturday'),
(strtotime('last Saturday + 1 day') - $saturday) / 86400,
(strtotime('last Saturday + 2 day') - $saturday) / 86400,
(strtotime('last Saturday + 3 day') - $saturday) / 86400,
(strtotime('last Saturday + 4 day') - $saturday) / 86400,
(strtotime('last Saturday + 5 day') - $saturday) / 86400,
(strtotime('last Saturday + 6 day') - $saturday) / 86400,
(strtotime('last Saturday + 7 day') - $saturday) / 86400,
(strtotime('last Saturday + 8 day') - $saturday) / 86400,
(strtotime('last Saturday + 9 day') - $saturday) / 86400,
$sunday = strtotime('last Sunday'),
(strtotime('last Sunday + 1 day') - $sunday) / 86400,
(strtotime('last Sunday + 2 day') - $sunday) / 86400,
(strtotime('last Sunday + 3 day') - $sunday) / 86400,
(strtotime('last Sunday + 4 day') - $sunday) / 86400,
(strtotime('last Sunday + 5 day') - $sunday) / 86400,
(strtotime('last Sunday + 6 day') - $sunday) / 86400,
(strtotime('last Sunday + 7 day') - $sunday) / 86400,
(strtotime('last Sunday + 8 day') - $sunday) / 86400,
(strtotime('last Sunday + 9 day') - $sunday) / 86400,
$monday = strtotime('last Monday'),
(strtotime('last Monday + 1 day') - $monday) / 86400,
(strtotime('last Monday + 2 day') - $monday) / 86400,
(strtotime('last Monday + 3 day') - $monday) / 86400,
(strtotime('last Monday + 4 day') - $monday) / 86400,
(strtotime('last Monday + 5 day') - $monday) / 86400,
(strtotime('last Monday + 6 day') - $monday) / 86400,
(strtotime('last Monday + 7 day') - $monday) / 86400,
(strtotime('last Monday + 8 day') - $monday) / 86400,
(strtotime('last Monday + 9 day') - $monday) / 86400
);
Expected result:
----------------
int(1573880400)
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(7)
int(8)
int(9)
int(1573362000)
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(7)
int(8)
int(9)
int(1573448400)
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(7)
int(8)
int(9)
Actual result:
--------------
int(1573880400)
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(7)
int(8)
int(9)
int(1573362000)
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(14)
int(15)
int(16)
int(1573448400)
int(1)
int(2)
int(3)
int(4)
int(5)
int(6)
int(7)
int(8)
int(9)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78827&edit=1