PHPackages                             fast-forward/clock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. fast-forward/clock

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

fast-forward/clock
==================

A PSR-20 compliant clock implementation for PHP, with support for time zones and a service provider for easy integration with Fast Forward Container.

v1.0.0(2mo ago)02601MITPHPPHP ^8.3CI passing

Since Apr 7Pushed 2mo agoCompare

[ Source](https://github.com/php-fast-forward/clock)[ Packagist](https://packagist.org/packages/fast-forward/clock)[ Docs](https://github.com/php-fast-forward)[ RSS](/packages/fast-forward-clock/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (1)

FastForward\\Clock
==================

[](#fastforwardclock)

[![PHP Version](https://camo.githubusercontent.com/3cd770b20545837658262654c7c1cdb3b59cd82ebca19d6408dfe66b0ff9430f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e332532422d626c75652e737667)](https://www.php.net/)[![Composer Package](https://camo.githubusercontent.com/8b41f2e0be5b8def1bcf5af8ae735d74b0d89ac980ed364899c5b82ac543a834/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d666173742d2d666f7277617264253246636c6f636b2d4632384431412e7376673f6c6f676f3d636f6d706f736572266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/fast-forward/clock)[![PSR-20](https://camo.githubusercontent.com/81b4127cbaf1bcd6af0c2284486d5cbeac4e0bea1253b5bd84b2f96cee3df65b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d32302d636c6f636b2d3737376262342e737667)](https://www.php-fig.org/psr/psr-20/)[![Tests](https://github.com/php-fast-forward/clock/actions/workflows/tests.yml/badge.svg)](https://github.com/php-fast-forward/clock/actions/workflows/tests.yml)[![Coverage](https://camo.githubusercontent.com/b07f431b6190776261e940002bc328c3f4ec49951ccf348bace854b6732be029/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d706870756e69742d677265656e)](https://php-fast-forward.github.io/clock/coverage/index.html)[![License](https://camo.githubusercontent.com/31980f78030a78d5f57c699e27de54d931d6632d451e6b2cabd3034b45fbf18b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068702d666173742d666f72776172642f636c6f636b)](https://opensource.org/licenses/MIT)

FastForward\\Clock provides PSR-20 compliant clock implementations and seamless integration with [Fast Forward Container](https://github.com/php-fast-forward/container).

This package offers two clock implementations: `SystemClock` for production time and `FrozenClock` for deterministic testing.

✨ Features
----------

[](#-features)

- 🕒 **PSR-20 Compliant** - Full support for the PSR-20 Clock interface
- 🧪 **Testing Made Easy** - `FrozenClock` lets you freeze time for reliable tests
- 🌐 **Timezone Support** - Configure timezones in production and tests
- 🔌 **Container Integration** - Automatic service registration via `ClockServiceProvider`
- 🎯 **Beginner Friendly** - Simple API designed for developers new to PSR patterns

📦 Installation
--------------

[](#-installation)

```
composer require fast-forward/clock
```

Requirements:

- PHP 8.3 or higher
- `fast-forward/container` 1.6 or higher
- `psr/clock` 1.0

🛠️ Usage
--------

[](#️-usage)

### Basic: Get the current time

[](#basic-get-the-current-time)

The simplest way to get the current time is using `SystemClock`:

```
