Bug #54909 [Com]: Relative weekday modifications reset time values.
| From: | mozeeiran at outlook dot com | Date: | Mon, 25 Oct 2021 19:33:29 +0000 |
| Subject: | Bug #54909 [Com]: Relative weekday modifications reset time values. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-237375@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54909&edit=1
ID: 54909
Comment by: mozeeiran at outlook dot com
Reported by: salathe@php.net
Summary: Relative weekday modifications reset time values.
Status: Open
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
از Ù
ÛØ§Ù ÙÙØ±ÙØ§Û Ù
ÙØ¬Ùد در
اجتÙ
اع Ù
Ø§Ø Ú©Ù
تر Ù
ÙØ±Ø¯Û Ù
اÙÙØ¯
Ù
ÙØ²ÛÚ© Ù
خاطبا٠پرشÙ
ار Ù Ù
تÙÙØ¹
را ب٠سÙ
تâÙØ³ÙÛ Ø®ÙØ¯ Ø¬ÙØ¨
Ù
ÛâÚ©ÙØ¯. Ù
اÙÛØª Ù
ÙØ²ÛÚ©Ø ÙÛØ§Ø² بÙ
Ø´ÙÛØ¯Ù Ù Ø´ÙÛØ¯ÙâØ´Ø¯Ù Ø§Ø³Øª ک٠در
Ø²ÛØ¨Ø§ØªØ±ÛÙ Ù ÙÙØ±ÛâØªØ±ÛÙ Ø´Ú©Ù
Ù
Ù
ک٠٠در ÙØ§Ùب Ø¢ÙØ§Ùا Ù
ÙÙØ§ÙاÛÛ ÙÙ
اÙÙÚ¯ Ù ÙØ§Ø±Ù
ÙÙÛÚ©Ø
عرض٠Ù
ÛâØ´ÙØ¯. بÙâØ¬Ø±Ø£Øª
Ù
ÛâØªÙØ§Ù Ú¯ÙØª ÙÛÚ ÙÙØ±Û در
ساÙâÙØ§Û Ø§Ø®ÛØ±Ø تا اÛÙ ØØ¯
ÙØ²Ø¯ÛÚ©Ø Ø¢Ø´ÙØ§ ٠بÛâÙØ§Ø³Ø·Ù با
ØÙاس آدÙ
Û Ø§Ø±ØªØ¨Ø§Ø· Ø¨Ø±ÙØ±Ø§Ø±
Ùکرد٠است. Ø¢Ù
ار Ø¨Ø§ÙØ§Û داÙÙÙØ¯
Ø¢ÙÙÚ¯ Ø®ÙØ§ÙÙØ¯Ú¯Ø§Ù پاپ در Ø·Û ÙØ±
Ø±ÙØ² را Ù
ÛâØªÙØ§Ù از ÙØ´Ø§ÙÙâÙØ§Û
بارز ٠آشکار اÛÙ ÙØ§ÙØ¹ÛØª
Ø¯Ø§ÙØ³Øª.
https://muziran.ir/داÙÙÙØ¯-Ø¢ÙÙÚ¯-Ø¬Ø¯ÛØ¯/
Previous Comments:
------------------------------------------------------------------------
[2021-09-21 12:45:23] cmb@php.net
Comparing <https://3v4l.org/OhHNJ> and <https://3v4l.org/N337o>
this looks like a bug to me, but after that long time, it might as
well be considered a documentation issue.
------------------------------------------------------------------------
[2016-06-10 03:05:25] amakhrov at gmail dot com
This still happens in php 7.0.x version (Linux, MacOSX)
Looks like the related behavior is defined here:
https://github.com/php/php-src/blob/master/ext/date/lib/parse_date.re#L669..L673
------------------------------------------------------------------------
[2015-09-23 17:45:33] jeff at nd4c dot com
This bug has been verified that it still exists in the following versions:
PHP version 5.6.6 for Windows, Apache/2.4.12 (Win32)
PHP version 5.4.42 for Linux, Apache/2.2.15 (CentOS)
------------------------------------------------------------------------
[2015-09-23 17:34:37] jeff at nd4c dot com
This bug also applies to the strtotime() function.
<?php
$start = '2015-09-25 11:25:23';
$formats = array(
'1 second',
'1 minute',
'1 hour',
'1 day',
'1 weekday',
'1 weeks',
'1 month',
'1 year',
);
echo "Start\t\t\tDateTime\t\tstrtotime\t\tformat\n";
foreach ($formats as $format):
$datetime = new DateTime($start);
echo $datetime->format('Y-m-d H:i:s')."\t";
$datetime->modify($format);
echo date('Y-m-d H:i:s', strtotime($format, strtotime($start)))."\t";
echo $format."\n";
endforeach;
?>
Outputs:
Start DateTime strtotime format
2015-09-25 11:25:23 2015-09-25 11:25:24 2015-09-25 11:25:24 1 second
2015-09-25 11:25:23 2015-09-25 11:26:23 2015-09-25 11:26:23 1 minute
2015-09-25 11:25:23 2015-09-25 12:25:23 2015-09-25 12:25:23 1 hour
2015-09-25 11:25:23 2015-09-26 11:25:23 2015-09-26 11:25:23 1 day
2015-09-25 11:25:23 2015-09-28 00:00:00 2015-09-28 00:00:00 1 weekday
2015-09-25 11:25:23 2015-10-02 11:25:23 2015-10-02 11:25:23 1 weeks
2015-09-25 11:25:23 2015-10-25 11:25:23 2015-10-25 11:25:23 1 month
2015-09-25 11:25:23 2016-09-25 11:25:23 2016-09-25 11:25:23 1 year
------------------------------------------------------------------------
[2011-05-23 15:55:55] salathe@php.net
Description:
------------
Date modifications utilizing the "weekdays" keyword change the resulting date to
have zero values for hour/minute/second units. Prior to PHP 5.3.6, the time
values were unaffected.
Test script:
---------------
<?php
$dt = new DateTime('2011-05-10 12:34:56', new DateTimeZone('UTC'));
$dt->modify('10 weekdays');
echo $dt->format('r');
?>
Expected result:
----------------
Tue, 24 May 2011 12:34:56 +0000
Actual result:
--------------
Tue, 24 May 2011 00:00:00 +0000
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=54909&edit=1