1. Go to this page and download the library: Download colopl/colopl_timeshifter 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/ */
colopl / colopl_timeshifter example snippets
Colopl\ColoplTimeShifter\Manager;
// Shift the current time to 2021-01-01 00:00:00 UTC.
Manager::hookDateTime(new DateTimeImmutable('2021-01-01 00:00:00 UTC'));
echo date('Y-m-d H:i:s');
echo time();
Manager::unhook();
use function Colopl\ColoplTimeShifter\register_hook;
use function Colopl\ColoplTimeShifter\unregister_hook;
$target = new DateTimeImmutable('2021-01-01 00:00:00 UTC');
register_hook($target->diff(new DateTimeImmutable()));
echo date('Y-m-d H:i:s');
echo time();
unregister_hook();
bash
$ git clone --recursive "https://github.com/colopl/php-colopl_timeshifter.git" "colopl_timeshifter"
$ cd "colopl_timeshifter/ext"
$ phpize
$ ./configure --with-php-config="$(which php-config)"
$ make -j"$(nproc)"
$ TEST_PHP_ARGS="--show-diff -q" make test
$ sudo make install