[php-src] Issue #9761: fix $datetime->modify("now")
| From: | divinity76 | Date: | Mon, 17 Oct 2022 08:43:12 +0000 |
| Subject: | [php-src] Issue #9761: fix $datetime->modify("now") | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242611@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9761
Author: divinity76
### Description
currently (and imo, surprisingly) when doing
```php
<?php
$dt = new DateTime();
sleep(2);
$dt->modify("now");
```
the modify() call does.. absolutely nothing. imo this is bad: if it is truly an unsupported
operation, modify() should have thrown, or at least made a warning like
$dt->modify("Chuck Norris"); generates Warning: DateTime::modify():
Failed to parse time string (Chuck Norris) at position 0 (C)
but it would be even better if it was a supported operation, changing the timestamp to the current
time, like doing $dt->setTimestamp(time()); with millisecond/microsecond/etc
precision