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 is intentionally minimal, 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, omitting ISO 8601 serialization for now due to ambiguity, excluding floating-point methods to avoid precision/rounding issues, using the `Time` namespace (aligned with Rust, Java, and Go conventions), and accepting only ISO 8601 '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 JavaScript Temporal API's `temporal_rs` library (rejected due to language semantic differences and Zend Engine integration complexity).

2h 14m read timeFrom externals.io
Post cover image
427 Impressions