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
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 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.