{"id":36265549,"url":"https://github.com/upyx/php-time","last_synced_at":"2026-01-11T08:02:24.785Z","repository":{"id":57075928,"uuid":"227452395","full_name":"upyx/php-time","owner":"upyx","description":"Object oriented representation of time and time only (without date, timezone or something else).","archived":false,"fork":false,"pushed_at":"2019-12-12T18:07:38.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T01:43:54.693Z","etag":null,"topics":["library","php","time"],"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/upyx.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":"2019-12-11T20:18:05.000Z","updated_at":"2022-01-18T20:18:09.000Z","dependencies_parsed_at":"2022-08-24T14:40:28.559Z","dependency_job_id":null,"html_url":"https://github.com/upyx/php-time","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/upyx/php-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyx%2Fphp-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyx%2Fphp-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyx%2Fphp-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyx%2Fphp-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/upyx","download_url":"https://codeload.github.com/upyx/php-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/upyx%2Fphp-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28297978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T04:44:51.577Z","status":"ssl_error","status_checked_at":"2026-01-11T04:44:44.232Z","response_time":60,"last_error":"SSL_read: 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":["library","php","time"],"created_at":"2026-01-11T08:02:23.950Z","updated_at":"2026-01-11T08:02:24.754Z","avatar_url":"https://github.com/upyx.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# upyx/php-time\n\n[![Source Code][badge-source]][source]\n[![Latest Version][badge-release]][packagist]\n[![Software License][badge-license]][license]\n[![PHP Version][badge-php]][php]\n[![Build Status][badge-build]][build]\n[![Coverage Status][badge-coverage]][coverage]\n[![Total Downloads][badge-downloads]][downloads]\n\nObject oriented representation of time with microseconds. It like o'clock time\nwithout date, timezone or something else but cyclical for 24 hours.\n\n\n## Why not DateTime/DateTimeImmutable from standard library?\n\nIt is for different purposes. DateTime uses for calendar (linear) time through\nages. But this library is intended to represent periodical time day by day.\n\nLet's look closer. Noon in Tokyo and noon in New York are different times in\nthe world. Noon on the 1st of December and noon on the 2nd December are\ndifferent times. But noon is still 12 **o'clock**.\n\nIt is still possible to use DateTime for o'clock time, but it has some\ndisadvantages. Firstly, it is curly because it needs some \"zero-date\".\nSecondary, it is difficult to compare and calculate because of changing dates.\nThirdly, it is buggy because of timezone conversions. Fourthly, it confuses\nwith the DateTime type used as calendar time.\n\n\n## Installation\n\nThe preferred method of installation is via [Composer][]. Run the following\ncommand to install the package and add it as a requirement to your project's\n`composer.json`:\n\n```bash\ncomposer require upyx/php-time\n```\n\n\n## Usage\n\nLocalTime can be created in three ways:\n\n```php\nuse Upyx\\PhpTime\\LocalTime;\n$time1 = new LocalTime(10, 20, 30, 40000);\n$time2 = LocalTime::fromDateTime(new DateTimeImmutable('10:20:30'));\n$time3 = LocalTime::fromMicroseconds(3600000000);\n```\n\nThere are \"add\" and \"subtract\" methods:\n\n```php\nuse Upyx\\PhpTime\\LocalTime;\n$time1 = new LocalTime(10, 0);\n$time2 = new LocalTime(13, 0);\nvar_dump($time1-\u003ecyclicAdd($time2)); // 23:00:00.000000\nvar_dump($time2-\u003ecyclicSubtract($time1)); // 03:00:00.000000\nvar_dump($time1-\u003ecyclicSubtract($time2)); // 21:00:00.000000\n```\n\nAs time is periodical, there are two distances between two times in\nboth directions. There is a method to calculate the smallest distance\nbetween ones:\n\n```php\nuse Upyx\\PhpTime\\LocalTime;\n$time1 = new LocalTime(2, 0);\n$time2 = new LocalTime(12, 0);\n$time3 = new LocalTime(22, 0);\nvar_dump($time1-\u003ecalcDistance($time2)); // 10:00:00.000000\nvar_dump($time2-\u003ecalcDistance($time3)); // 10:00:00.000000\nvar_dump($time1-\u003ecalcDistance($time3)); // 04:00:00.000000\n```\n\nIt is possible to use comparison operators.\nThe smallest value is \"00:00:00.000000\", the greatest one is \"23:59:59.999999\".\n\n```php\nuse Upyx\\PhpTime\\LocalTime;\n$time1 = new LocalTime(10, 0);\n$time2 = new LocalTime(13, 0);\nvar_dump($time1 \u003c $time2); // true\nvar_dump($time1 \u003c= $time2); // true\nvar_dump($time1 \u003e $time2); // false\nvar_dump($time1 \u003e= $time2); // false\nvar_dump($time1 \u003c=\u003e $time2); // -1\n```\n\n\n## Contributing\n\nIf you have a question, feel free to create an issue. If you would like to send\nme a pull request, please create an issue first.\n\n\n## Copyright and License\n\nThe upyx/php-time library is copyright © Sergey Rabochiy\nand licensed for use under the MIT License (MIT). Please see [LICENSE][] for\nmore information.\n\n\n[composer]: https://getcomposer.org/\n\n[badge-source]: https://img.shields.io/badge/source-upyx/php--time-blue.svg?style=flat\n[badge-release]: https://img.shields.io/packagist/v/upyx/php-time.svg?style=flat\u0026label=release\n[badge-license]: https://img.shields.io/packagist/l/upyx/php-time.svg?style=flat\n[badge-php]: https://img.shields.io/packagist/php-v/upyx/php-time.svg?style=flat\n[badge-build]: https://img.shields.io/travis/upyx/php-time/master.svg?style=flat\n[badge-coverage]: https://img.shields.io/coveralls/github/upyx/php-time/master.svg?style=flat\n[badge-downloads]: https://img.shields.io/packagist/dt/upyx/php-time.svg?style=flat\u0026colorB=mediumvioletred\n\n[source]: https://github.com/upyx/php-time\n[packagist]: https://packagist.org/packages/upyx/php-time\n[license]: https://github.com/upyx/php-time/blob/master/LICENSE\n[php]: https://php.net\n[build]: https://travis-ci.org/upyx/php-time\n[coverage]: https://coveralls.io/r/upyx/php-time?branch=master\n[downloads]: https://packagist.org/packages/upyx/php-time\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupyx%2Fphp-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fupyx%2Fphp-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fupyx%2Fphp-time/lists"}