Skip to content
A helper to control the flow of time
Branch: master
Clone or download
Latest commit 09e1228 Jun 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Add create, createFromDate, createFromTime, createFromTimeString and … Jun 16, 2019
tests wip Jun 12, 2019
.editorconfig wip Jun 12, 2019
.gitattributes wip Jun 12, 2019
.gitignore wip Jun 12, 2019
.scrutinizer.yml wip Jun 12, 2019
.styleci.yml wip Jun 12, 2019
.travis.yml wip Jun 12, 2019 Update Jun 16, 2019 wip Jun 12, 2019 wip Jun 12, 2019
composer.json wip Jun 12, 2019
phpunit.xml.dist wip Jun 12, 2019

A helper to control the flow of time

Latest Version on Packagist Build Status StyleCI Quality Score Total Downloads

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

// we're now one year in the future

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


You can install the package via composer:

composer require spatie/test-time


You can freeze the time with:


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


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.



// you can also chain calls


composer test


Please see CHANGELOG for more information on what has changed recently.


Please see CONTRIBUTING for details.


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


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, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards on our company website.


Support us

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.


The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.