PHPackages                             isaacongoma/test-time - 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. isaacongoma/test-time

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

isaacongoma/test-time
=====================

A small package to control the flow time

1.2.2(5y ago)05MITPHPPHP ^7.2|^8.0

Since Jun 12Pushed 5y agoCompare

[ Source](https://github.com/isaacongoma/test-time)[ Packagist](https://packagist.org/packages/isaacongoma/test-time)[ Docs](https://github.com/spatie/test-time)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/isaacongoma-test-time/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (10)Used By (0)

A helper to control the flow of time
====================================

[](#a-helper-to-control-the-flow-of-time)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ac61c16c67a2b3ede244451f72ffe261160b34883753f691ac3731fd30f891f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f746573742d74696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/test-time)[![GitHub Workflow Status](https://camo.githubusercontent.com/e604680803f7ed33dc83f6190162851218232ef2e52937813959f5d50cc86fc3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f746573742d74696d652f72756e2d74657374733f6c6162656c3d7465737473)](https://camo.githubusercontent.com/e604680803f7ed33dc83f6190162851218232ef2e52937813959f5d50cc86fc3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f746573742d74696d652f72756e2d74657374733f6c6162656c3d7465737473)[![StyleCI](https://camo.githubusercontent.com/5578e04f7b0ddda63e9e771326b62b34d70ff39e0c184ef60087f6c1c37bb460/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3139313537333537392f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/191573579)[![Quality Score](https://camo.githubusercontent.com/b6eed26407f294683f66855525ff721d89937f617f02c06df6e578399fa91a31/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f746573742d74696d652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/test-time)[![Total Downloads](https://camo.githubusercontent.com/348115cea5c8464ebf2cb943c8e734e36f9b5b69368c72998509409d04c2d032/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f746573742d74696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/test-time)

[Carbon](https://github.com/briannesbitt/Carbon) is an excellent library to work with time in PHP projects. The `Spatie\TestTime\TestTime` class contains a few functions that under the hood manipulate the time that's considered the current time by Carbon.

```
// the flow of time is frozen
TestTime::freeze();

// we're now one year in the future
TestTime::addYear();

// will report the real current year + 1
$year = (new Carbon())->format('Y');
```

Are you a visual learner?
-------------------------

[](#are-you-a-visual-learner)

[In this video](https://www.youtube.com/watch?v=1dJphbcWRxI), you'll learn how we use this package to test time sensitive functionality in [Mailcoach](https://mailcoach.app).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/d5556f7b044bf19b176b4fdf30e1a76ff52ac96833129c24e8893ca4577e80cf/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f746573742d74696d652e6a70673f743d31)](https://spatie.be/github-ad-click/test-time)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/test-time
```

Usage
-----

[](#usage)

You can freeze the time with:

```
TestTime::freeze();
```

Alternatively you can pass in a carbon instance that will be used as the current time.

```
TestTime::freeze($carbonInstance);
```

You can also pass a format and time.

```
TestTime::freeze('Y-m-d', '2019-06-12');
```

You can progress the time with any of the carbon functions starting with `add` or `sub`.

```
TestTime::addMinute();

TestTime::subHours(5);

// you can also chain calls
TestTime::addMonth(3)->addYear();
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [Alex Vanderbist](https://github.com/AlexVanderbist)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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

Every ~63 days

Recently: every ~126 days

Total

9

Last Release

2068d ago

Major Versions

0.0.1 → 1.0.02019-06-12

PHP version history (3 changes)0.0.1PHP ^7.1

1.0.0PHP ^7.2

1.2.2PHP ^7.2|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21239787?v=4)[Isaac Ongoma](/maintainers/isaacongoma)[@isaacongoma](https://github.com/isaacongoma)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (38 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (4 commits)")[![veneliniliev](https://avatars.githubusercontent.com/u/5311085?v=4)](https://github.com/veneliniliev "veneliniliev (4 commits)")[![isaacongoma](https://avatars.githubusercontent.com/u/21239787?v=4)](https://github.com/isaacongoma "isaacongoma (3 commits)")[![MatanYadaev](https://avatars.githubusercontent.com/u/13586343?v=4)](https://github.com/MatanYadaev "MatanYadaev (3 commits)")[![pascalbaljet](https://avatars.githubusercontent.com/u/8403149?v=4)](https://github.com/pascalbaljet "pascalbaljet (2 commits)")[![aryehraber](https://avatars.githubusercontent.com/u/5065331?v=4)](https://github.com/aryehraber "aryehraber (1 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (1 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (1 commits)")

---

Tags

spatietest-time

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/isaacongoma-test-time/health.svg)

```
[![Health](https://phpackages.com/badges/isaacongoma-test-time/health.svg)](https://phpackages.com/packages/isaacongoma-test-time)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[spatie/laravel-sitemap

Create and generate sitemaps with ease

2.6k16.6M147](/packages/spatie-laravel-sitemap)[spatie/temporary-directory

Easily create, use and destroy temporary directories

975102.5M264](/packages/spatie-temporary-directory)[spatie/test-time

A small package to control the flow time

2085.2M154](/packages/spatie-test-time)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.8M75](/packages/spatie-laravel-honeypot)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69619.8M640](/packages/spatie-phpunit-snapshot-assertions)

PHPackages © 2026

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