PHP code example of spatie / test-time

1. Go to this page and download the library: Download spatie/test-time library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spatie / test-time example snippets


// 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');

TestTime::freeze();

TestTime::freeze($carbonInstance);

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

TestTime::addMinute();

TestTime::subHours(5);

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

TestTime::unfreeze();