psx/datetime
PSX DateTime is a PHP library for working with dates and times, offering utilities for parsing, formatting, timezone conversion, and date arithmetic. It integrates with the PSX framework and provides a lightweight, object-oriented API for common temporal tasks in PHP applications.
Architecture fit
psx/datetime is a value-object datetime model modeled on JSR310: Instant, LocalDate, LocalDateTime, ZonedDateTime, Duration vs. Period, and an injectable Clock. That is a genuinely better semantic model than DateTime for anything involving explicit time zones, calendar arithmetic, or testable "now".DateTimeInterface and Carbon. Eloquent casts, Illuminate\Support\Carbon, validation rules (date, after_or_equal), Blade format()/diffForHumans(), queue payload serialization, Model::freshTimestamp(), and most first-party and third-party packages all assume native datetime objects. psx/datetime objects almost certainly do not implement DateTimeInterface, which makes them non-interchangeable with that spine.ZonedDateTime escaping into a controller, cast, or event payload and forcing every downstream consumer to learn the library.Integration feasibility
PSX\DateTime namespace. Conflict risk is near zero.composer.json's require.php constraint, whether it drags in psx/common, and whether the test suite runs green on the PHP version your Laravel release requires (8.2/8.3/8.4). A JSR310-era port plausibly predates typed properties, return types, and str_contains-era refactors, and may hit PHP 8.1+ deprecations (implicit nullable parameters, dynamic properties) or fatal errors on newer runtimes.Technical risk
brick/date-time is a mature, actively maintained JSR310 port with broad adoption; Carbon 3 and native DateTimeImmutable cover the rest. Adopting this specific package over those needs a reason beyond "it's a JSR310 port".Duration vs. Period in month arithmetic, and DST resolution rules may not match what your DB driver or Carbon produces for the same input.Key questions
require.php constraint, and does the suite pass on the PHP versions our Laravel release supports?DateTimeInterface anywhere, or is every boundary conversion ours to write?brick/date-time?Stack fit
DateTimeImmutable at the edges, psx/datetime in the domain core. Persistence stays timestamp/timestamptz columns with standard Eloquent casts. API resources emit ISO-8601/RFC 3339 strings. Only the domain service touches PSX\DateTime.brick/date-time or Carbon 3's immutable API.Migration path Not a migration — an isolated adoption with an exit ramp.
app/Support/Time/ containing fromNative() / toNative() / toIso() mappers, a Clock binding in the container for deterministic tests, and an Eloquent custom cast if persistence is unavoidable.brick/date-time.Compatibility
psx/* requirements.Sequencing
| Phase | Output | Gate |
|---|---|---|
| 0 | PHP/Composer compatibility check, CI run | Suite green on our runtime |
| 1 | Capability spike vs. Carbon on real data | Demonstrated semantic win |
| 2 | Adapter module + contract tests | Boundary tests green incl. DST |
| 3 | One bounded-context adoption, flagged | No type leakage in review |
| 4 | 30-day review | Adapter surface stable, or revert |
Maintenance
Support
Scaling
DateTimeImmutable in hot loops — measurable at millions of operations, irrelevant at typical business-logic volumes.Failure modes
Ramp-up
Instant vs. LocalDateTime vs. ZonedDateTime, Duration vs. Period).Verdict: the JSR310 model is worth having; this package is a hard sell at 2 stars, 0 dependents, and a single maintainer. Approve only as a fenced, forked, single-bounded-context experiment with a defined exit ramp — otherwise take brick/date-time or stay on Carbon and solve the problem with DateTimeImmutable plus explicit timezone handling.
How can I help you explore Laravel packages today?