A PHP internals mailing list thread discussing a proposed RFC to introduce a new `Time\Duration` class in PHP 8.6. The class is designed to represent stopwatch-style durations (not calendar periods) to improve developer experience for timeout APIs, particularly the new Polling API. The RFC proposes a minimal API using seconds+nanoseconds internal representation, with constructors like `Duration::fromHours()` and parsing via `Duration::fromIso8601String()`. Discussion covers design decisions including: why floating-point methods were omitted (precision/rounding concerns), why the `Time` namespace was chosen over `DateTime`, ISO 8601 string format clarifications, whether to use `add`/`sub` vs a variadic `sum()` method, and why using the JavaScript Temporal `temporal_rs` Rust library was rejected in favor of a PHP-native API.

57m read timeFrom externals.io
Post cover image
410 Impressions