{"id":37263064,"url":"https://github.com/lsv/timestringparser","last_synced_at":"2026-01-15T23:44:11.104Z","repository":{"id":62519499,"uuid":"59542207","full_name":"lsv/timestringparser","owner":"lsv","description":"Parse a text string to minutes in integer","archived":false,"fork":false,"pushed_at":"2017-04-05T14:01:35.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T23:50:20.429Z","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/lsv.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-05-24T05:13:45.000Z","updated_at":"2022-08-24T17:02:20.000Z","dependencies_parsed_at":"2022-11-02T13:18:12.221Z","dependency_job_id":null,"html_url":"https://github.com/lsv/timestringparser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/lsv/timestringparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsv%2Ftimestringparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsv%2Ftimestringparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsv%2Ftimestringparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsv%2Ftimestringparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsv","download_url":"https://codeload.github.com/lsv/timestringparser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsv%2Ftimestringparser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-15T23:44:10.428Z","updated_at":"2026-01-15T23:44:11.098Z","avatar_url":"https://github.com/lsv.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Time string parser \u0026#9679; [![Build Status](https://travis-ci.org/lsv/timestringparser.svg?branch=master)](https://travis-ci.org/lsv/timestringparser) [![Coverage Status](https://coveralls.io/repos/github/lsv/timestringparser/badge.svg?branch=master)](https://coveralls.io/github/lsv/timestringparser?branch=master)\n===========================================================================================================================================================================================================================================================================================================================\n\nIf you have strings like 1h30m and want this to be a integer with minutes, this is for you.\n\nThe hour letters and minute letters can be customized and also multiple is allowed.\n\n* 1h20m = 80\n* 3:24 = 204\n* 954 = 954\n\nAnd if you have multiple hour letters you can set these in the constructor, see under [usage](#Usage), so you can end up with parsing multiple letters\n \n* 2t20 = 140\n* 3x84s = 264\n\n##### New in 2.0\n\n* You can now add a low minute, meaning if set it to 4, then if you write 3, it will become 3 hours, if you write 5 it will still be 5 minutes.\n* By default the `low minute` variable is NULL, meaning its not used\n\n### Install\n\n`composer require lsv/timestringparser`\n\nor add\n\n```json\n{\n    \"require\": {\n        \"lsv/timestringparser\": \"^1.0\"\n    }\n}\n```\n\nto your `composer.json`\n\n### Usage\n\nBy standard hour letter is `h` and minute letter is `m` but these can be customized in the constructor `new TimestringParser(['h','t','u'], ['m','x','y']);` now `h`, `t` and `u` can be used to parse the hour part of the time string, and the letters `m`, `x`, `y` can be used to parse the minute part of the time string\n \n##### New in 2.0\n\nYou can set the `low minute` variable in the constructor `new TimestringParser(['h','t','u'], ['m','x','y'], \u003clow minute\u003e);`\n\nIt needs to be a integer\n \n### Examples\n\n```php\n$timestrings = [\n    '3:20', '1h 42m', '1u 22x', '3u55x',\n    20, '1h', '48h84y', '3t994x'\n];\n$parser = new TimestringParser(['h','t','u'], ['m','x','y']);\nforeach($timestrings as $string) {\n    echo $parser-\u003eparseTimeString($string); // Return integers\n}\n```\n\n##### Low minute example\n\n```\n$timestrings = [1, 2, '3', '4', 5];\n$parser = new TimestringParser(['h'], ['m'], 3);\necho $parser-\u003eparseTimeString(1); // Returns 60\necho $parser-\u003eparseTimeString(2); // Returns 120\necho $parser-\u003eparseTimeString('3'); // Returns 180\necho $parser-\u003eparseTimeString('4'); // Returns 4\necho $parser-\u003eparseTimeString(5); // Returns 5\n```\n\n### License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Martin Aarhof \u003cmartin.aarhof@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsv%2Ftimestringparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsv%2Ftimestringparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsv%2Ftimestringparser/lists"}