{"id":27091670,"url":"https://github.com/dgame/php-time","last_synced_at":"2025-04-06T07:53:23.593Z","repository":{"id":48939769,"uuid":"60962210","full_name":"Dgame/php-time","owner":"Dgame","description":"Convert TimeUnits to other TimeUnits in no time.","archived":false,"fork":false,"pushed_at":"2021-07-18T18:37:06.000Z","size":108,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T22:47:22.979Z","etag":null,"topics":["php","time","timeunit"],"latest_commit_sha":null,"homepage":"","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/Dgame.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}},"created_at":"2016-06-12T10:51:24.000Z","updated_at":"2023-03-19T17:44:27.000Z","dependencies_parsed_at":"2022-09-22T14:38:43.167Z","dependency_job_id":null,"html_url":"https://github.com/Dgame/php-time","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dgame","download_url":"https://codeload.github.com/Dgame/php-time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247451629,"owners_count":20940946,"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":["php","time","timeunit"],"created_at":"2025-04-06T07:53:23.028Z","updated_at":"2025-04-06T07:53:23.579Z","avatar_url":"https://github.com/Dgame.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-time\n\n## Convert TimeUnits to other TimeUnits in no time.\n\n### Seconds:\n```php\nseconds(300)-\u003einMinutes()-\u003eequalsAmount(5);\n```\n\n#### Minutes:\n```php\nminutes(60)-\u003einSeconds()-\u003eequalsAmount(3600);\nminutes(60)-\u003einHours()-\u003eequalsAmount(1);\n```\n\n#### Hours:\n```php\nhours(24)-\u003einMinutes()-\u003eequalsAmount(1440);\nhours(24)-\u003einDays()-\u003eequalsAmount(1);\n```\n\n### Days:\n```php\ndays(7)-\u003einHours()-\u003eequalsAmount(168);\ndays(7)-\u003einWeeks()-\u003eequalsAmount(1);\n```\n\n### Weeks:\n```php\nweeks(12)-\u003einDays()-\u003eequalsAmount(84);\n```\n\n### Months:\n```php\nmonths(12)-\u003einYears()-\u003eequalsAmount(1);\n```\n\n### Years:\n```php\nyears(1)-\u003einWeeks()-\u003eequalsAmount(52);\nyears(2)-\u003einMonths()-\u003eequalsAmount(24);\n```\n\n## Compare TimeUnits:\n\n```php\nhours(24)-\u003eequals(days(1));\ndays(1)-\u003eequals(hours(24));\nyears(1)-\u003eequals(days(365));\nweeks(1)-\u003eequals(days(7));\n```\n\n## Add / Subtract TimeUnits:\n\n```php\ndays(1)-\u003eadd(hours(24))-\u003eequals(days(2));\nhours(24)-\u003esubtract(days(0.5))-\u003eequals(hours(12));\nhours(1)-\u003eequals(minutes(60));\n```\n\n----\n\n## Get specific informations about a Month / Year\n\nThere  is a **Month** and a **Year** class (note the missing `s` at the end) to access precise informations about a specific year or a specific month in a specific year:\n\n### Month:\n```php\nMonth::Of('Feb', 2015)-\u003einDays()-\u003eequalsAmount(28);\nMonth::Of('Feb', 2015)-\u003einWeeks()-\u003eequalsAmount(4);\nMonth::Of('Feb', 2016)-\u003einDays()-\u003eequalsAmount(29);\nMonth::Of('Jun', 2016)-\u003einDays()-\u003eequalsAmount(30);\nMonth::Of('Jun', 2016)-\u003einWeeks()-\u003eequalsAmount(4.28571);\n```\n\n### Year:\n```php\nYear::Of(2016)-\u003eisLeapyear();\nYear::Of(2015)-\u003einDays()-\u003eequalsAmount(365);\nYear::Of(2016)-\u003einDays()-\u003eequalsAmount(366);\nYear::Of(2015)-\u003einWeeks()-\u003eequalsAmount(52.142857142857);\nYear::Of(2016)-\u003einWeeks()-\u003eequalsAmount(52.285714285714);\n```\n\n----\n\n## Represent a TimeUnit in individual units\n\n```php\n$unit = new TimeUnits(days(1000));\n\n$this-\u003eassertTrue($unit-\u003egetYears()-\u003eequalsAmount(2));\n$this-\u003eassertTrue($unit-\u003egetMonths()-\u003eequalsAmount(8));\n$this-\u003eassertTrue($unit-\u003egetWeeks()-\u003eequalsAmount(3));\n$this-\u003eassertTrue($unit-\u003egetDays()-\u003eequalsAmount(5));\n$this-\u003eassertTrue($unit-\u003egetHours()-\u003eequalsAmount(11));\n$this-\u003eassertTrue($unit-\u003egetMinutes()-\u003eequalsAmount(33));\n$this-\u003eassertTrue($unit-\u003egetSeconds()-\u003eequalsAmount(20));\n```\n\n```php\n$unit = new TimeUnits(hours(4.5));\n\n$this-\u003eassertTrue($unit-\u003egetYears()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetMonths()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetWeeks()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetDays()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetHours()-\u003eequalsAmount(4));\n$this-\u003eassertTrue($unit-\u003egetMinutes()-\u003eequalsAmount(30));\n$this-\u003eassertTrue($unit-\u003egetSeconds()-\u003eequalsAmount(0));\n```\n\n```php\n$unit = new TimeUnits(minutes(525));\n\n$this-\u003eassertTrue($unit-\u003egetYears()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetMonths()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetWeeks()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetDays()-\u003eequalsAmount(0));\n$this-\u003eassertTrue($unit-\u003egetHours()-\u003eequalsAmount(8));\n$this-\u003eassertTrue($unit-\u003egetMinutes()-\u003eequalsAmount(45));\n$this-\u003eassertTrue($unit-\u003egetSeconds()-\u003eequalsAmount(0));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgame%2Fphp-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgame%2Fphp-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgame%2Fphp-time/lists"}