>
> just like the constructor accepts
> new DateTime("@0.123456"); // 1970-01-01 00:00:00.123456
> new DateTime("@".microtime(true));
>
> IMO setTimestamp should accept the same:
> $dt->setTimestamp(0.123456); // 1970-01-01 00:00:00.123456
> $dt->setTimestamp(microtime(true));
>
> Can we change setTimestamp to accept int|float?
> made a PR https://github.com/php/php-src/pull/13383

You are probably already aware, but PHP 8.4 will have a new
`DateTime::get/setMicroseconds` method[^1][^2] that accepts an integer
microsecond value.

That said, I personally think it makes sense to accept float values
for fractions of seconds, but changing the parameter type WILL be be a
BC break because all subclasses extending `setTimestamp` will not be
compatible unless they are changed to `int|float` or wider.


[^1]: 
https://github.com/php/php-src/commit/0016b3085cf06e8a189ecc53c31697e3a108dbdd
[^2]: https://php.watch/versions/8.4/date-datetime-get-setMicroseconds

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to