{"id":34650326,"url":"https://github.com/roaatech/php-time","last_synced_at":"2026-05-29T14:31:25.061Z","repository":{"id":56994588,"uuid":"68689390","full_name":"roaatech/php-time","owner":"roaatech","description":"Time class","archived":false,"fork":false,"pushed_at":"2016-10-04T19:58:10.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-08-14T14:13:19.706Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/roaatech.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-09-20T08:10:18.000Z","updated_at":"2020-10-30T14:19:20.000Z","dependencies_parsed_at":"2022-08-21T10:40:46.821Z","dependency_job_id":null,"html_url":"https://github.com/roaatech/php-time","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/roaatech/php-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roaatech%2Fphp-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roaatech%2Fphp-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roaatech%2Fphp-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roaatech%2Fphp-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roaatech","download_url":"https://codeload.github.com/roaatech/php-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roaatech%2Fphp-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33657690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-12-24T17:55:30.619Z","updated_at":"2026-05-29T14:31:25.052Z","avatar_url":"https://github.com/roaatech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-time\n\nA PHP class to easily create and maintain time values. You can create the object from a string like \"1:22:13.212\" or timestamps and it will automatically parse and fetch values.\n\nYou can then update the values, or convert it into strings or timestamps.\n\n## Creating the object\n You can create the object from empty value, or from a string, or a timestamp. i.e.\n ```php\n $time1 = new \\ItvisionSy\\Time\\Time(); //Time is set to \"0:0:0.000\"\n $time2 = new \\ItvisionSy\\Time\\Time(\"1:22:18.212\");\n $time3 = new \\ItvisionSy\\Time\\Time(36232518212);\n ```\n Also you can use the `make($time)` factory method:\n ```php\n $time1 = \\ItvisionSy\\Time\\Time::make();\n $time2 = \\ItvisionSy\\Time\\Time::make(\"12:46:36.897\");\n $time3 = \\ItvisionSy\\Time\\Time::make(3600000);\n ```\n \n ### Time string\n Time string is a string with 4 parts as follows:\n `h[:i[:s[.m]]]`. I.e: \n ```php\n \\ItvisionSy\\Time\\Time::make('3')-\u003eformat(); //3:0:0.0 \n \\ItvisionSy\\Time\\Time::make('3:30')-\u003eformat(); //3:30:0.0 \n \\ItvisionSy\\Time\\Time::make('3:30:22')-\u003eformat(); //3:30:22.0 \n \\ItvisionSy\\Time\\Time::make('3:30:22.123')-\u003eformat(); //3:30:22.123 \n ```\n If milliseconds digits are more than 3, only first 3 will be used.\n Also, you can use irregular (overflown) values and it will be automatically converted into the next unit. i.e.\n ```php\n \\ItvisionSy\\Time\\Time::make('3:90')-\u003eformat(); //4:30:0.0 \n \\ItvisionSy\\Time\\Time::make('0:180')-\u003eformat(); //3:0:0.0 \n ```\n \n ## Setting values\n You can use the methods: `hours($value)`, `minutes($value)`, `seconds($value)`, or `millis($value)` to update the value. The `$value` parameter can be either an integer which will replace the old value, or a string preceded with \"+\" or \"-\" to alter the current value. i.e.\n ```php\n $time = \\ItvisionSy\\Time\\Time::make()-\u003ehours(4); //sets the hours to 4\n $time-\u003ehourse(\"+3\"); //sets the hours to 7 (4+3)\n $time-\u003ehours(0)-\u003eminutes(128)-\u003eseconds(61)-\u003eformat(); //returns 2:9:1.000\n ```\n You can also use the direct assignment which will call the previous methods. i.e.\n ```php\n $time = \\ItvisionSy\\Time\\Time::make(\"1:2:3.4\");\n $time-\u003ehours = 33;\n $time-\u003eseconds = \"-22\";\n ```\n Or you can use the parser method\n ```php\n $time-\u003eparseString(\"22:11:12.123\");\n ```\n \n ## Getting values\n You can either use the methods or the properties\n ```php\n $time-\u003ehours; // === $time-\u003ehours()\n $time-\u003eminutes; // === $time-\u003eminutes()\n $time-\u003eseconds; // === $time-\u003eseconds()\n $time-\u003emillis; // === $time-\u003emillis()\n ```\n \n ## Utilities\n ### Formatting\n `format(boolean $leadingZeros = false)` \n ```php\n $time = \\ItvisionSy\\Time\\Time::make(\"6:3:7.23\");\n $time-\u003eminutes(\"+123\");\n $time-\u003eformat(); //\"8:6:7.23\"\n $time-\u003eformat(true); //\"8:06:07.023\"\n ```\n### Representing\n You can represent the timestamp in a unit like hours or minutes. \n ```php\n $time = \\ItvisionSy\\Time\\Time::make(\"2:30:00.000\");\n ```\n### Comparing\n####Diff function\n```php\nuse \\ItvisionSy\\Time\\Time; \nTime::make('3')-\u003ediff(Time::make(2))-\u003einHours; //3:0:0.0   \n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froaatech%2Fphp-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froaatech%2Fphp-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froaatech%2Fphp-time/lists"}