codemonster-ru / datetime
Immutable date-time operations, strict parsing, timezone conversion, localization, business calendars, and PSR-20 clocks.
Requires
- php: >=8.2
- psr/clock: ^1.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.6 || ^10.5 || ^11.0 || ^12.0
Suggests
- ext-intl: Required for localized date-time and human interval formatting.
This package is auto-updated.
Last update: 2026-07-31 04:34:09 UTC
README
Important
This repository is read-only.
Development happens in the Annabel monorepo.
Issues and pull requests should be opened there.
Immutable date-time operations, timezone conversion, strict parsing, ICU formatting, business calendars, and PSR-20 clocks for PHP applications.
Requirements
- PHP 8.2 or newer
psr/clock1.0ext-intlwith the required ICU locale data for localized and human-readable formatting
Installation
composer require codemonster-ru/datetime:^1.0
Quick start
use Codemonster\DateTime\DateTime; use Codemonster\DateTime\FrozenClock; $clock = new FrozenClock(new \DateTimeImmutable('2026-07-31 05:30:00 UTC')); $publishedAt = DateTime::now($clock, 'Asia/Novokuznetsk') ->addDays(2) ->subtractHours(3) ->toTimezone('UTC'); echo $publishedAt->toIso8601String();
All value operations are immutable. Calendar units such as days and months preserve local calendar semantics, while hours, minutes, and seconds represent elapsed time.
Documentation
Standalone package documentation: docs.codemonster.net/datetime
Annabel framework documentation: docs.codemonster.net/annabel