{"id":15525364,"url":"https://github.com/ghostwriter/clock","last_synced_at":"2025-06-18T03:06:36.327Z","repository":{"id":197118298,"uuid":"697910925","full_name":"ghostwriter/clock","owner":"ghostwriter","description":"Provides an immutable Clock implementation for PHP","archived":false,"fork":false,"pushed_at":"2025-06-16T16:50:18.000Z","size":451,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"3.0.x","last_synced_at":"2025-06-16T17:51:58.168Z","etag":null,"topics":["clock","ghostwriter"],"latest_commit_sha":null,"homepage":"https://github.com/ghostwriter/clock","language":"PHP","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/ghostwriter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["ghostwriter"]}},"created_at":"2023-09-28T18:17:14.000Z","updated_at":"2025-06-16T16:50:21.000Z","dependencies_parsed_at":"2023-09-29T03:39:28.062Z","dependency_job_id":"36677200-94e8-4451-aa07-150bebffdfff","html_url":"https://github.com/ghostwriter/clock","commit_stats":null,"previous_names":["ghostwriter/clock"],"tags_count":5,"template":false,"template_full_name":"ghostwriter/wip","purl":"pkg:github/ghostwriter/clock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fclock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fclock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fclock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fclock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostwriter","download_url":"https://codeload.github.com/ghostwriter/clock/tar.gz/refs/heads/3.0.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fclock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260477921,"owners_count":23015064,"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":["clock","ghostwriter"],"created_at":"2024-10-02T10:57:05.547Z","updated_at":"2025-06-18T03:06:31.312Z","avatar_url":"https://github.com/ghostwriter.png","language":"PHP","funding_links":["https://github.com/sponsors/ghostwriter"],"categories":[],"sub_categories":[],"readme":"# Clock\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/ghostwriter?label=Sponsor+@ghostwriter/clock\u0026logo=GitHub+Sponsors)](https://github.com/sponsors/ghostwriter)\n[![Automation](https://github.com/ghostwriter/clock/actions/workflows/automation.yml/badge.svg)](https://github.com/ghostwriter/clock/actions/workflows/automation.yml)\n[![Supported PHP Version](https://badgen.net/packagist/php/ghostwriter/clock?color=8892bf)](https://www.php.net/supported-versions)\n[![Downloads](https://badgen.net/packagist/dt/ghostwriter/clock?color=blue)](https://packagist.org/packages/ghostwriter/clock)\n\nProvides an immutable Clock implementation for PHP\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require ghostwriter/clock\n```\n\n### Star ⭐️ this repo if you find it useful\n\nYou can also star (🌟) this repo to find it easier later.\n\n### Usage\n\n``` php\n\u003c?php\n\n// Internally uses SystemClock::new(new DateTimeZone(date_default_timezone_get()));\n\ndate_default_timezone_set('America/Los_Angeles');\n$systemClock = SystemClock::new();\n$systemClock-\u003enow(); // DateTimeImmutable\n$systemClock-\u003enow()-\u003egetTimezone()-\u003egetName(); // America/Los_Angeles\n\ndate_default_timezone_set('America/New_York');\n$systemClock = SystemClock::new();\n$systemClock-\u003enow(); // DateTimeImmutable\n$systemClock-\u003enow()-\u003egetTimezone()-\u003egetName(); // America/New_York\n\n$localizedClock = LocalizedClock::new();\n$localizedClock-\u003enow(); // DateTimeImmutable\n$localizedClock-\u003enow()-\u003egetTimezone()-\u003egetName(); // UTC\n\n$localizedClock = LocalizedClock::new(new DateTimeZone('Africa/Addis_Ababa'));\n$localizedClock-\u003enow(); // DateTimeImmutable\n$localizedClock-\u003enow()-\u003egetTimezone()-\u003egetName(); // Africa/Addis_Ababa\n\n$frozenClock = FrozenClock::new(new DateTimeImmutable('now', new DateTimeZone('UTC')));\n$frozenClock-\u003enow(); // DateTimeImmutable\n$frozenClock-\u003enow()-\u003egetTimezone()-\u003egetName(); // UTC\n```\n\n### API\n\n``` php\ninterface ClockInterface\n{\n    public function freeze(): FrozenClockInterface;\n\n    public function now(): DateTimeImmutable;\n}\n\ninterface FrozenClockInterface extends ClockInterface\n{\n    public static function new(DateTimeImmutable $dateTimeImmutable): self;\n}\n\ninterface LocalizedClockInterface extends ClockInterface\n{\n    public static function new(DateTimeZone $dateTimeZone): self;\n}\n\ninterface SystemClockInterface extends ClockInterface\n{\n    public static function new(): self;\n}\n```\n\n### Changelog\n\nPlease see [CHANGELOG.md](./CHANGELOG.md) for more information what has changed recently.\n\n### Security\n\nIf you discover any security related issues, please email `nathanael.esayeas@protonmail.com` or create a [Security Advisory](https://github.com/ghostwriter/clock/security/advisories/new) instead of using the issue tracker.\n\n## License\n\nThe BSD-4-Clause. Please see [License File](./LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Fclock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostwriter%2Fclock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Fclock/lists"}