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: the highest constructor unit being hours, omitting ISO 8601 serialization for now due to ambiguity, excluding floating-point total methods to avoid precision/rounding issues, using the `Time` namespace (aligned with Rust, Java, and Go conventions rather than JavaScript's Temporal), and accepting only ISO 8601 'Period' strings starting with 'PT'. Community feedback raises questions about add/sub vs. a variadic sum method, namespace choice, and whether to adopt the temporal_rs Rust library instead of building a new API from scratch.

1h 10m read timeFrom externals.io
Post cover image
500 Impressions