Tim Düsterhus and Derick are proposing a new `Time\Duration` class for PHP 8.6 to represent stopwatch-style durations, primarily to improve developer experience for timeout APIs and the new Polling API. The class uses a seconds + nanoseconds internal representation (similar to Rust's and Java's Duration), supports constructors up to hours, and includes `Duration::fromIso8601String` accepting ISO-8601 period strings starting with 'PT'. The RFC is intentionally minimal, deferring features like ISO-8601 serialization and floating-point total methods to future versions. Discussion touches on namespace choice (`Time` vs `DateTime`), floating-point precision concerns, and alignment with Rust/Java/Go conventions. This is positioned as the first step in a modernized PHP date/time API, following the pattern of new namespaced APIs introduced in PHP 8.2–8.5.

8m read timeFrom externals.io
Post cover image
163 Impressions