php-pico / clock
PSR-20 compliant clock package.
0.1.0
2025-12-10 20:25 UTC
Requires
- php: ^8.4
- psr/clock: ^1.0
Requires (Dev)
- carthage-software/mago: ^1.0.0-rc.12
- phpunit/phpunit: ^12.5
This package is not auto-updated.
Last update: 2026-03-05 19:48:32 UTC
README
PSR-20 compliant clock package.
Usage
use PhpPico\Clock\Clock; new Clock()->now(); // returns a DateTimeImmutable
This package is great for testing, since you can set a mock "now" which you can use when testing.
use PhpPico\Clock\Clock; $testNow = new DateTimeImmutable('2025-01-01 12:00:00'); // 1st January 2025 12:00 Clock::setTestNow($testNow); new Clock()->now(); // Returns the $testNow DateTimeImmutable