{"id":22576097,"url":"https://github.com/colopl/php-colopl_timeshifter","last_synced_at":"2025-04-10T17:12:09.762Z","repository":{"id":246747961,"uuid":"822424496","full_name":"colopl/php-colopl_timeshifter","owner":"colopl","description":"PHP modify current time extension for testing, DO NOT USE PRODUCTION","archived":false,"fork":false,"pushed_at":"2024-11-27T05:10:23.000Z","size":64,"stargazers_count":3,"open_issues_count":1,"forks_count":3,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-24T14:51:26.458Z","etag":null,"topics":["extension","library","php","php8"],"latest_commit_sha":null,"homepage":"https://colopl.co.jp","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colopl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-07-01T06:09:48.000Z","updated_at":"2025-03-21T14:20:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"0c1a055f-84c7-408c-b9d4-98c8f724d0b4","html_url":"https://github.com/colopl/php-colopl_timeshifter","commit_stats":null,"previous_names":["colopl/php-colopl_timeshifter"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_timeshifter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_timeshifter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_timeshifter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colopl%2Fphp-colopl_timeshifter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colopl","download_url":"https://codeload.github.com/colopl/php-colopl_timeshifter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261905,"owners_count":21074224,"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":["extension","library","php","php8"],"created_at":"2024-12-08T04:06:04.482Z","updated_at":"2025-04-10T17:12:09.739Z","avatar_url":"https://github.com/colopl.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# colopl_timeshifter\n\nThis extension changes the current time in PHP to a specified modified value.\n\n\u003e [!WARNING]\n\u003e **DO NOT USE THIS EXTENSION IN ANY PRODUCTION ENVIRONMENT!!!**\n\nAt present, this extension is effective for the following functions:\n\n- Any built-in PHP processing that handles the current time (`ext-date`)\n- `NOW()` and many statements in MySQL or compatible DBMS via PDO\n- Server environment variables for request time (e.g. `S_SERVER['REQUEST_TIME']`)\n\n## Setup\n\n```bash\n$ git clone --recursive \"https://github.com/colopl/php-colopl_timesifter.git\" \"colopl_timeshifter\"\n$ cd \"colopl_timeshifter/ext\"\n$ phpize\n$ ./configure --with-php-config=\"$(which php-config)\"\n$ make -j$(nproc)\n$ TEST_PHP_ARGS=\"-q --show-diff\" make test\n$ sudo make install\n```\n\nAnd enable extension.\n\n```\n$ sudo echo \"extension=colopl_timesfhiter\" \u003e \"$(php-config --ini-dir)/99-colopl_timeshifter.ini\"\n$ php -m | grep colopl_timeshifter\ncolopl_timeshifter\n```\n\n### PHP Library (recommended)\n\n```bash\n$ composer require --dev \"colopl/colopl_timeshifter\"\n```\n\nAnd use `Colopl\\ColoplTimeShifter\\Manager` class.\n\n## INI directives\n\n#### `colopl_timeshifter.is_hook_pdo_mysql`\n\nType: `bool`\nDefault: `true`\nRun-time switchable: **No** (`PHP_INI_SYSTEM`)\n\nEnables or disables the hook into `\\PDO::__construct` to swap the current time in MySQL function and keywords (e.g. `NOW()`, `CURRENT_TIMESTAMP`)\n\n#### `colopl_timeshifter.is_hook_request_time`\n\nType: `bool`\nDefault: `true`\nRun-time switchable: **No** (`PHP_INI_SYSTEM`)\n\nSelects whether to hook the $_SERVER superglobals `REQUEST_TIME` and `REQUEST_TIME_FLOAT`.\n\n#### `colopl_timeshifter.usleep_sec`\n\nType: `int` (`int\u003c1, max\u003e`)\nDefalt: `1`\nRun-time switchable: **Yes** (`PHP_INI_ALL`)\n\nFor a string representing time, set the number of wait microseconds to check whether it is absolute or relative time.\n\n#### `colopl_timeshifter.is_restore_per_request`\n\nType: `bool`\nDefault: `false`\nRun-time switchable: **Yes** (`PHP_INI_ALL`)\n\nSets whether or not to unhook at the end of the request.\n\n## Functions\n\n\u003e [!TIP]\n\u003e Install `colopl/colopl_timeshifter` **Composer** package and use `Colopl\\ColoplTimeShifter\\Manager` support class instead.\n\n#### `\\Colopl\\ColoplTimeShifter\\register_hook(\\DateInterval $interval): bool`\n\nSets the time difference to be subtracted from the current time.\n\nIf the hook succeeds, it returns `true`; otherwise, it returns `false`.\n\n#### `\\Colopl\\ColoplTimeShifter\\unregister_hook(): void`\n\nBreaks the hook.\n\n#### `\\Colopl\\ColoplTimeShifter\\is_hooked(): bool`\n\nCheck to see if the hook is done. Returns `true` if the hook is done, `false` otherwise.\n\n## License\n\nPHP License 3.01\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolopl%2Fphp-colopl_timeshifter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolopl%2Fphp-colopl_timeshifter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolopl%2Fphp-colopl_timeshifter/lists"}