PHPackages                             kuria/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. [Testing &amp; Quality](/categories/testing)
4. /
5. kuria/clock

ActiveLibrary[Testing &amp; Quality](/categories/testing)

kuria/clock
===========

Provides access to current date and time that can be mocked for testing purposes

v1.0.0(7y ago)011.0k↓52.1%2MITPHPPHP &gt;=7.1

Since Sep 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kuria/clock)[ Packagist](https://packagist.org/packages/kuria/clock)[ RSS](/packages/kuria-clock/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (2)

Clock
=====

[](#clock)

Provides access to current date and time that can be mocked for testing purposes.

[![https://travis-ci.com/kuria/clock.svg?branch=master](https://camo.githubusercontent.com/d0860379801dfaad30c4e1b1751b5956c376475bd36f64561eab798c6174d9d7/68747470733a2f2f7472617669732d63692e636f6d2f6b757269612f636c6f636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/kuria/clock)Contents

- [Requirements](#requirements)
- [Usage](#usage)
    - [Getting current time](#getting-current-time)
    - [Overriding current time](#overriding-current-time)

[Requirements](#id1)
--------------------

[](#requirements)

- PHP 7.1+

[Usage](#id2)
-------------

[](#usage)

The `Kuria\Clock\Clock` class provides access to current date and time.

### [Getting current time](#id3)

[](#getting-current-time)

- `Clock::time(): int`
    - get the current UNIX timestamp
- `Clock::microtime(): float`
    - get the current UNIX timestamp with microsecond precision
- `Clock::dateTime(?\DateTimeZone $timezone = null): \DateTime`
    - get the current date-time
    - uses default time zone if not specified
- `Clock::dateTimeImmutable(?\DateTimeZone $timezone = null): \DateTimeImmutable`
    - get the current date-time as an immutable instance
    - uses default time zone if not specified

### [Overriding current time](#id4)

[](#overriding-current-time)

- `Clock::override($now): void`
    - override the current time
    - `$now` can be an UNIX timestamp or an instance of `DateTimeInterface`
    - `$now` can include microseconds
    - this change only affects methods of the `Clock` class
- `Clock::isOverridden(): bool`
    - see if the current time is currently overridden
- `Clock::resume(): void`
    - resume normal operation after the time has been overridden
    - if the time is not currently overridden, this method does nothing

Note

Time overriding is intended only for testing purposes.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2847d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e42ecd45c6085272adb572590764b739256cb372af72940fb712d7b5a2cf4313?d=identicon)[Shira](/maintainers/Shira)

---

Top Contributors

[![shira-374](https://avatars.githubusercontent.com/u/1024071?v=4)](https://github.com/shira-374 "shira-374 (6 commits)")

---

Tags

datedate-timemockphptestclockdatetimetimenowdateoverride

### Embed Badge

![Health badge](/badges/kuria-clock/health.svg)

```
[![Health](https://phpackages.com/badges/kuria-clock/health.svg)](https://phpackages.com/packages/kuria-clock)
```

###  Alternatives

[psr/clock

Common interface for reading the clock.

646378.5M528](/packages/psr-clock)[cakephp/chronos

A simple API extension for DateTime.

1.4k50.2M145](/packages/cakephp-chronos)[jenssegers/date

A date library to help you work with dates in different languages

1.8k11.5M84](/packages/jenssegers-date)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

185701.7M5.6k](/packages/nesbot-carbon)[carbonphp/carbon-doctrine-types

Types to use Carbon in Doctrine

220257.6M10](/packages/carbonphp-carbon-doctrine-types)[brick/date-time

Date and time library

3663.8M108](/packages/brick-date-time)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
