php-pico / clock
PSR-20 compliant clock package.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/php-pico/clock
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: 2025-12-11 18:43:19 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