DateTime
Date, time and datetime primitives for Raxos, built on top of CakePHP Chronos. The package ships three small, immutable value classes (Date, Time and DateTime) that extend Chronos with JSON serialization, string parsing and a regex pattern contract. It also provides Month and Weekday enums, a small DateTimeUtil helper, and optional ORM casters for raxos/database.
Install it with Composer.
shell
composer require raxos/datetimeHighlights
DateTimeImmutable datetime value object built on CakePHP Chronos.DateImmutable date value object with JSON and route binding support.TimeImmutable time of day value object.DateTimeUtilSmall static helpers for time and ISO week calculations.Explore by category
- Date, Time and DateTime: the three core value objects, how they extend Chronos, and how string parsing and JSON serialization work.
- Enums and utilities: the
MonthandWeekdayenums and theDateTimeUtilhelper functions. - ORM casters: the optional casters for raxos/database model properties.
Quick example
php
<?php
declare(strict_types=1);
use Raxos\DateTime\{DateTime, Weekday};
$now = DateTime::now();
$weekday = Weekday::fromChronos($now);
echo $now->toIso8601String();
echo $weekday->name;This creates the current DateTime and resolves the matching Weekday case.
Next steps
See installation for requirements, or use the sidebar to navigate this package.