innmind / time-continuum
Library to manipulate time
4.0.0
2024-11-28 19:39 UTC
Requires
- php: ~8.2
- innmind/immutable: ~5.0
- psr/log: ~3.0
Requires (Dev)
- innmind/black-box: ~5.8
- innmind/coding-standard: ^2.0.1
- vimeo/psalm: ~5.13
Suggests
- innmind/black-box: For property based testing
Provides
Conflicts
- innmind/black-box: <5.0|~6.0
This package is auto-updated.
Last update: 2024-11-29 16:51:57 UTC
README
This library allows you to handle time down to the millisecond. The point was to also be explicit for every component of dates, this is why every php magic strings have been converted into objects.
All objects are immutable.
Installation
composer install innmind/time-continuum
Usage
use Innmind\TimeContinuum\{ Clock, PointInTime, Format, }; use Innmind\Immutable\Maybe; $clock = Clock::live(); $now = $clock->now(); // return an instance of PointInTime echo $now->toString(); // 2016-10-11T12:17:30.123456+02:00 $epoch = $clock->at( '1970-01-01T00:00:00.000000+00:00', Format::iso8601(), ); // Maybe<PointInTime>
Here we reference 2 points in time, the first is the exact moment we call now
down to the microsecond and the second one is the epoch time.
The method at()
accepts any string that is allowed by \DateTimeImmutable
.
Documentation
Full documentation is available at https://innmind.org/TimeContinuum/.