Bug #76945 [Opn]: DateTime modify with decimals
| From: | wijnand at samson-it dot nl | Date: | Fri, 28 Sep 2018 13:17:45 +0000 |
| Subject: | Bug #76945 [Opn]: DateTime modify with decimals | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217267@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76945&edit=1
ID: 76945
User updated by: wijnand at samson-it dot nl
Reported by: wijnand at samson-it dot nl
Summary: DateTime modify with decimals
Status: Open
Type: Bug
Package: Date/time related
PHP Version: 7.2.10
Block user comment: N
Private report: N
New Comment:
I suppose you're referring to this:
[+-]?[0-9]+
Then it's still not correct, because the "+1." part of the string is dropped, instead
of it saying that this is not recognised.
Previous Comments:
------------------------------------------------------------------------
[2018-09-28 12:13:05] salathe@php.net
> It's not documented
The relative date/time statements (and how they behave with non-relative statements) are documented
at http://php.net/manual/en/datetime.formats.relative.php
------------------------------------------------------------------------
[2018-09-28 11:43:49] wijnand at samson-it dot nl
Description:
------------
---
From manual page: http://www.php.net/datetime.modify
---
Let's modify a DateTime object, say "add one-and-a-half hour". The expected result is
that 1 hour and 30 minutes are added. The actual result is that 5 hours are added.
It's not necessarily a problem that the decimal syntax is not supported, however there's
no warning that this doesn't work. It's not documented and the call is happily accepted. I
would say that the regex should be "\+\d+" or something along those lines.
Test script:
---------------
(new DateTime('2000-01-01 0:00'))->modify('+1.5 hours');
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76945&edit=1