{"id":13828249,"url":"https://github.com/spatie/test-time","last_synced_at":"2025-05-15T02:08:10.526Z","repository":{"id":45925404,"uuid":"191573579","full_name":"spatie/test-time","owner":"spatie","description":"A helper to control the flow of time","archived":false,"fork":false,"pushed_at":"2025-03-19T10:40:00.000Z","size":62,"stargazers_count":207,"open_issues_count":0,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-07T23:03:53.276Z","etag":null,"topics":["carbon","php","testing","tests","time"],"latest_commit_sha":null,"homepage":"https://freek.dev/1378-a-package-to-control-the-flow-of-time","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"spatie","custom":"https://spatie.be/open-source/support-us"}},"created_at":"2019-06-12T13:11:51.000Z","updated_at":"2025-04-04T21:26:30.000Z","dependencies_parsed_at":"2025-04-11T09:56:01.656Z","dependency_job_id":"9d0f9a9f-2354-47c8-87c9-0c94d77b09ef","html_url":"https://github.com/spatie/test-time","commit_stats":{"total_commits":70,"total_committers":10,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"93bdf7405632e75752ef63983caf4983033114b2"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftest-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftest-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftest-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Ftest-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/test-time/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259384,"owners_count":22040820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carbon","php","testing","tests","time"],"created_at":"2024-08-04T09:02:38.378Z","updated_at":"2025-05-15T02:08:10.486Z","avatar_url":"https://github.com/spatie.png","language":"PHP","readme":"# A helper to control the flow of time\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/test-time.svg?style=flat-square)](https://packagist.org/packages/spatie/test-time)\n[![run-tests](https://github.com/spatie/test-time/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/test-time/actions/workflows/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/test-time.svg?style=flat-square)](https://packagist.org/packages/spatie/test-time)\n\n[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.\n\n```php\n// the flow of time is frozen\nTestTime::freeze();\n\n// we're now one year in the future\nTestTime::addYear();\n\n// will report the real current year + 1\n$year = (new Carbon())-\u003eformat('Y');\n```\n\n## Are you a visual learner?\n\n[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).\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/test-time.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/test-time)\n\nWe 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).\n\nWe 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).\n\n## Installation\n\nYou can install the package via composer. Probably you'll only need it when developing.\n\n```bash\ncomposer require spatie/test-time --dev\n```\n\n## Usage\n\nYou can freeze the time with:\n\n```php\nTestTime::freeze();\n```\n\nAlternatively you can pass in a carbon instance that will be used as the current time.\n\n```php\nTestTime::freeze($carbonInstance);\n```\n\nYou can also pass a format and time.\n\n```php\nTestTime::freeze('Y-m-d', '2019-06-12');\n```\n\n### Progressing time\n\nYou can progress the time with any of the carbon functions starting with `add` or `sub`.\n\n```php\nTestTime::addMinute();\n\nTestTime::subHours(5);\n\n// you can also chain calls\nTestTime::addMonth(3)-\u003eaddYear();\n```\n\n### Unfreezing time\n\nTo let time flow naturally again, call  `unfreeze`.\n\n```php\nTestTime::unfreeze();\n```\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n### Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Postcardware\n\nYou'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.\n\nOur address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.\n\nWe publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [Alex Vanderbist](https://github.com/AlexVanderbist)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":["https://github.com/sponsors/spatie","https://spatie.be/open-source/support-us"],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Ftest-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Ftest-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Ftest-time/lists"}