Tim Düsterhus and Derick Rethans have proposed a new `Time\Duration` class for PHP 8.6 to represent stopwatch-style durations, primarily to improve the developer experience for timeout APIs including the new Polling API. The RFC is intentionally minimal, using a seconds+nanoseconds internal representation (similar to Rust's and Java's Duration). The mailing list discussion covers design decisions including: why the highest constructor unit is hours, the absence of ISO 8601 serialization (deferred to PHP 8.7), omission of floating-point total methods due to precision concerns, the choice of `Time` namespace over `DateTime`, and whether to use `add`/`sub` methods or a single variadic `sum` method. The authors also explain why they chose not to adopt the JavaScript Temporal API or the temporal_rs Rust library.

41m read timeFrom externals.io
Post cover image
384 Impressions