Tim Düsterhus and Derick Rethans have proposed a new `Time\Duration` class for PHP 8.6, designed to represent stopwatch-style or egg-timer durations for use in 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: limiting the highest constructor unit to hours, omitting ISO 8601 serialization for now due to ambiguity, excluding floating-point conversion methods to avoid precision/rounding issues, and using the `Time` namespace (aligned with Rust's `std::time`, Java's `java.time`, and Go's `time`). Community feedback raised questions about adding `getTotalSeconds()`, whether to use `Duration::sum()` instead of separate `add`/`sub` methods, and whether to adopt the JavaScript Temporal API's `temporal_rs` library (rejected due to language mismatch and Zend Engine integration complexity). The RFC is positioned as the first step toward a modernized PHP date/time API.

37m read timeFrom externals.io
Post cover image
435 Impressions