{"id":13608741,"url":"https://github.com/cakephp/chronos","last_synced_at":"2025-05-12T13:24:40.555Z","repository":{"id":1553706,"uuid":"42588972","full_name":"cakephp/chronos","owner":"cakephp","description":"A standalone DateTime library originally based off of Carbon","archived":false,"fork":false,"pushed_at":"2025-02-14T07:18:43.000Z","size":1330,"stargazers_count":1357,"open_issues_count":3,"forks_count":64,"subscribers_count":43,"default_branch":"3.x","last_synced_at":"2025-05-03T01:04:19.535Z","etag":null,"topics":["calendar-dates","datetime-objects","immutable-objects","library","mutable-objects","php","time"],"latest_commit_sha":null,"homepage":"http://book.cakephp.org/chronos","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/cakephp.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-16T13:30:45.000Z","updated_at":"2025-04-04T13:59:15.000Z","dependencies_parsed_at":"2023-09-22T13:25:06.511Z","dependency_job_id":"2666eed5-6df7-4419-97f0-7199a9d93c93","html_url":"https://github.com/cakephp/chronos","commit_stats":{"total_commits":586,"total_committers":69,"mean_commits":8.492753623188406,"dds":0.7798634812286689,"last_synced_commit":"419277b9cf23cb7fe74728618d8eb20841bcec94"},"previous_names":[],"tags_count":67,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fchronos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fchronos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fchronos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cakephp%2Fchronos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cakephp","download_url":"https://codeload.github.com/cakephp/chronos/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745887,"owners_count":21957461,"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":["calendar-dates","datetime-objects","immutable-objects","library","mutable-objects","php","time"],"created_at":"2024-08-01T19:01:29.609Z","updated_at":"2025-05-12T13:24:40.536Z","avatar_url":"https://github.com/cakephp.png","language":"PHP","readme":"# CakePHP Chronos\n\n![Build Status](https://github.com/cakephp/chronos/actions/workflows/ci.yml/badge.svg?branch=master)\n[![Latest Stable Version](https://img.shields.io/github/v/release/cakephp/chronos?sort=semver\u0026style=flat-square)](https://packagist.org/packages/cakephp/chronos)\n[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/chronos?style=flat-square)](https://packagist.org/packages/cakephp/chronos/stats)\n[![Code Coverage](https://img.shields.io/coveralls/cakephp/chronos/master.svg?style=flat-square)](https://coveralls.io/r/cakephp/chronos?branch=master)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\nChronos focuses on providing immutable date/datetime objects.\nImmutable objects help ensure that datetime objects aren't accidentally\nmodified keeping data more predictable.\n\n# Installation\n\nInstalling with composer:\n\n```\n$ composer require cakephp/chronos\n```\n\nYou can then use Chronos:\n\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse Cake\\Chronos\\Chronos;\n\nprintf(\"Now: %s\", Chronos::now());\n```\n\n# Differences with nesbot/carbon\n\nChronos was originally compatible with Carbon but has diverged and no longer\nextends the PHP DateTime and DateTimeImmutable classes.\n\n# Immutable Object Changes\n\nImmutable objects have a number of advantages:\n\n1. Using immutable objects is always free of side-effects.\n2. Dates and times don't accidentally change underneath other parts of your code.\n\nWith those benefits in mind, there are a few things you need to keep in mind\nwhen modifying immutable objects:\n\n```php\n// This will lose modifications\n$date = new Chronos('2015-10-21 16:29:00');\n$date-\u003emodify('+2 hours');\n\n// This will keep modifications\n$date = new Chronos('2015-10-21 16:29:00');\n$date = $date-\u003emodify('+2 hours');\n```\n\n# Calendar Dates\n\nPHP only offers datetime objects as part of the native extensions. Chronos adds\na number of conveniences to the traditional DateTime object and introduces\na `ChronosDate` object. `ChronosDate` instances their time frozen to `00:00:00` and the timezone\nset to the server default timezone. This makes them ideal when working with\ncalendar dates as the time components will always match.\n\n```php\nuse Cake\\Chronos\\ChronosDate;\n\n$today = new ChronosDate();\necho $today;\n// Outputs '2015-10-21'\n\necho $today-\u003emodify('+3 hours');\n// Outputs '2015-10-21'\n```\n\nLike instances of `Chronos`, `ChronosDate` objects are also *immutable*.\n\n# Documentation\n\nA more descriptive documentation can be found at [book.cakephp.org/chronos/3/en/](https://book.cakephp.org/chronos/3/en/).\n\n# API Documentation\n\nAPI documentation can be found on [api.cakephp.org/chronos](https://api.cakephp.org/chronos).\n","funding_links":[],"categories":["PHP","Libs","Common Plugins/Packages to solve difficult problems","目录","Table of Contents"],"sub_categories":["PHP","日期和时间 Date and Time","Date and Time"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fchronos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcakephp%2Fchronos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcakephp%2Fchronos/lists"}