Re: [RFC] Time\Instant and Time\Clock

From: Date: Fri, 25 Sep 2026 13:57:13 +0000
Subject: Re: [RFC] Time\Instant and Time\Clock
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-132636@lists.php.net to get a copy of this message
Hi On 2026-09-23 21:57, Théo Attali wrote:
If I may add one small suggestion: could toIso8601DateTimeString() be shortened to toIso8601String() and fromIso8601DateTimeString() to fromIso8601String() ? Since Time\Instant already represents a date-time value, these shorter names remain clear and are easier to use.
The proposed wording is consistent with Time\Duration::fromIso8601DurationString() which also includes the explicit “Duration” indicator. It also has some practical benefits: ISO-8601 defines a multitude of interchange formats that could be reasonably interpreted as being applicable, particularly with some components being implied as accepted by DateTimeImmutable. As an example Instant::fromIso8601String('2026-09-25') could be argued to mean “midnight UTC on 2026-09-25”. I believe the naming strikes an appropriate middle-ground between specific, while not being overly verbose and it leaves some future space for a toIso8601OrdinalDateTimeString() to emit 2026-268T13:55:00Z (with 268 referring to the 268th day of the year 2026), with the 2026-09-25 being the “calendar date” format, where the “calendar” part is being implied (and also the “extended” representation being implied). Best regards Tim Düsterhus

« previous php.internals (#132636) next »