PHPackages                             lcobucci/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lcobucci/clock

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lcobucci/clock
==============

Yet another clock abstraction

3.5.0(6mo ago)796190.9M—0.9%32[1 issues](https://github.com/lcobucci/clock/issues)20MITPHPPHP ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since May 7Pushed today3 watchersCompare

[ Source](https://github.com/lcobucci/clock)[ Packagist](https://packagist.org/packages/lcobucci/clock)[ GitHub Sponsors](https://github.com/lcobucci)[ Patreon](https://www.patreon.com/lcobucci)[ RSS](/packages/lcobucci-clock/feed)WikiDiscussions 3.7.x Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (32)Used By (20)

Clock
=====

[](#clock)

[![Total Downloads](https://camo.githubusercontent.com/2946ce3f9fc65f3f9c6c954629c47341b86018b303554001496bbdb254821cd2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c636f62756363692f636c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lcobucci/clock)[![Latest Stable Version](https://camo.githubusercontent.com/46c642bb23404f1b72558fb0f039433f42ff699e548d2a362d5259b7b986880b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c636f62756363692f636c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lcobucci/clock)[![Unstable Version](https://camo.githubusercontent.com/aa7c11b716eed3b3c0be0d9e65dc669ac3c73318fcb3ba00a490faa8431824ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f6c636f62756363692f636c6f636b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lcobucci/clock)

[![Build Status](https://camo.githubusercontent.com/15a51e09ffe3593aadcd2d7d11516b13cbd1dd86f4a2a43dc8ba9f122a4bdf0a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c636f62756363692f636c6f636b2f706870756e69742e796d6c3f6272616e63683d332e362e78267374796c653d666c61742d737175617265)](https://github.com/lcobucci/clock/actions?query=workflow%3A%22PHPUnit%20Tests%22+branch%3A3.6.x)[![Code Coverage](https://camo.githubusercontent.com/6e59051c9df80de400f034d3e85c6955b846819f3e0df6c61f5c8dc946e9f74e/68747470733a2f2f636f6465636f762e696f2f67682f6c636f62756363692f636c6f636b2f6272616e63682f332e342e782f67726170682f62616467652e737667)](https://codecov.io/gh/lcobucci/clock)

Yet another clock abstraction...

The purpose is to decouple projects from `DateTimeImmutable` instantiation so that we can test things properly.

Installation
------------

[](#installation)

Package is available on [Packagist](http://packagist.org/packages/lcobucci/clock), you can install it using [Composer](http://getcomposer.org).

```
composer require lcobucci/clock
```

Usage
-----

[](#usage)

Make your objects depend on the `Lcobucci\Clock\Clock` interface and use `SystemClock` or `FrozenClock` to retrieve the current time or a specific time (for testing), respectively:

```
