Search by

raxos / datetime

basmilius

Datetime primitives and utilities for Raxos.

3.2.0 2026-10-02 17:09 UTC

This package is auto-updated.

Last update: 2026-10-03 12:06:26 UTC


README

Bas Milius

Raxos DateTime

Immutable date, time and timestamp objects built on CakePHP Chronos.

Documentation | Packagist | Raxos

  • Date, Time and DateTime with Chronos arithmetic and formatting.
  • JSON serialization and parsing through StringParsableInterface.
  • Month and weekday enums, date utilities and ORM casters.

Installation

Requires PHP 8.5 or later. Composer checks the remaining package and extension dependencies declared in composer.json.

composer require "raxos/datetime:^3.2"

Usage

<?php
declare(strict_types=1);

use Raxos\DateTime\Date;
use Raxos\DateTime\DateTime;
use Raxos\DateTime\Time;

require __DIR__ . '/vendor/autoload.php';

$date = Date::parse('2026-10-03');
$tomorrow = $date->addDays(1);
$time = Time::parse('14:30:00');
$moment = DateTime::parse('2026-10-03 14:30:00', 'UTC');

echo json_encode(['date' => $tomorrow, 'time' => $time, 'moment' => $moment]);

Arithmetic returns new instances. Choose a timezone explicitly for timestamps; Date represents a calendar date and Time a time of day. Use the ORM casters with raxos/database installed.

Documentation

Testing

Run this library's Pest suite from the Raxos workspace:

git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=datetime

See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.

License

MIT. Copyright (c) 2017 - present Bas Milius.