Tim Düsterhus and Derick Rethans have proposed a new `Time\Duration` class for PHP 8.6, designed to represent stopwatch-style durations for timeout APIs. The RFC targets a minimal, correct API using a seconds+nanoseconds internal representation (similar to Rust's and Java's Duration). Key design decisions discussed include: the highest constructor unit being hours, intentional omission of ISO 8601 serialization and floating-point total methods for now, use of the `Time` namespace over `DateTime`, and the `fromIso8601String` method accepting only time-component period strings (starting with `PT`). Community feedback raised questions about adding `getTotalSeconds()`, a `sum()` method instead of separate `add`/`sub`, and whether to adopt the `temporal_rs` Rust library — which the authors declined, citing PHP-specific API design needs and Zend Engine integration complexity.

2h 4m read timeFrom externals.io
Post cover image
264 Impressions