{"id":20015479,"url":"https://github.com/ryanwinchester/carbonize","last_synced_at":"2025-05-04T22:31:33.158Z","repository":{"id":62538623,"uuid":"106921739","full_name":"ryanwinchester/carbonize","owner":"ryanwinchester","description":"Carbon helper","archived":false,"fork":false,"pushed_at":"2017-10-15T06:32:03.000Z","size":47,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T12:51:48.381Z","etag":null,"topics":["carbon","datetime","php"],"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/ryanwinchester.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":"2017-10-14T11:19:31.000Z","updated_at":"2022-03-29T01:15:58.000Z","dependencies_parsed_at":"2022-11-02T16:15:45.530Z","dependency_job_id":null,"html_url":"https://github.com/ryanwinchester/carbonize","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanwinchester%2Fcarbonize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanwinchester%2Fcarbonize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanwinchester%2Fcarbonize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanwinchester%2Fcarbonize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanwinchester","download_url":"https://codeload.github.com/ryanwinchester/carbonize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252408263,"owners_count":21743083,"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":["carbon","datetime","php"],"created_at":"2024-11-13T07:46:19.420Z","updated_at":"2025-05-04T22:31:32.758Z","avatar_url":"https://github.com/ryanwinchester.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Carbonize\n\n [![Packagist](https://img.shields.io/packagist/l/ryanwinchester/carbonize.svg)](https://packagist.org/packages/ryanwinchester/carbonize)\n [![Build Status](https://travis-ci.org/ryanwinchester/carbonize.svg?branch=master)](https://travis-ci.org/ryanwinchester/carbonize)\n [![Codecov](https://img.shields.io/codecov/c/github/ryanwinchester/carbonize.svg)](https://codecov.io/gh/ryanwinchester/carbonize)\n [![Maintainability](https://api.codeclimate.com/v1/badges/6d9cea21fa5324d48cca/maintainability)](https://codeclimate.com/github/ryanwinchester/carbonize/maintainability)\n\n\n[Carbon](https://github.com/briannesbitt/Carbon) helper for creating new instances of Carbon from other Carbon objects,\nDateTime|Immutable objects, date strings, timestamps, or null (for `now`).\n\nSometimes we have to work on projects that already exist or are underway, that are full of magic and inconsistent date formats.\nIs this going to be a timestamp? a date string? a Carbon instance? Does it even matter as long as it's a datetime of some sort? ¯\\\\\\_(ツ)\\_/¯\n\n```php\n    public function doMyThing($datetime)\n    {\n        // Whatever it was, it is _now_ a NEW carbon instance\n        $datetime = carbonize($datetime);\n\n        // do stuff with your carbon instance\n    }\n```\n\nYou can use it as either `carbonize()`, `carbon()`, or `Carbonize\\Carbonize::toCarbon()`.\n\n## Install\n\n```\ncomposer require ryanwinchester/carbonize\n```\n\nThis does not install carbon as a dependency, so add it yourself.\n\n**Important Note:** Please use Carbon 1.21 (not 1.22) until timezones are fixed. (https://github.com/briannesbitt/Carbon/issues/863)\n\n## What it does\n\n```php\ncarbonize() == Carbon::now(\"UTC\");\n\n$carbon = new Carbon();\ncarbonize($carbon) == $carbon-\u003ecopy();\n\n$dt = new DateTime();\ncarbonize($dt) == Carbon::instance($dt);\n\n$dtImmutable = new DateTimeImmutable();\ncarbonize($dtImmutable) == Carbon::instance(new DateTime($dtImmutable-\u003eformat(DateTime::ATOM)));\n\ncarbonize(1507957785) == Carbon::createFromTimestamp(1507957785, \"UTC\");\n\ncarbonize(\"1507957785\") == Carbon::createFromTimestamp(1507957785, \"UTC\");\n\ncarbonize(\"2017-01-01 12:04:01\") == Carbon::parse(\"2017-01-01 12:04:01\", \"UTC\");\n\ncarbonize(\"3 months ago\") == Carbon::parse(\"3 months ago\", \"UTC\");\n```\n\n## License\n\nMIT\n\n## Credits\n\n- **Carbon** (https://github.com/briannesbitt/Carbon)\n\n## Notes\n\nAlthough Carbon is decent, use [Chronos](https://github.com/cakephp/chronos) if you can. (https://github.com/cakephp/chronos)\n\n\u003c3 Chronos, Immutability FTW ᕙ(⇀‸↼‶)ᕗ\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanwinchester%2Fcarbonize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanwinchester%2Fcarbonize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanwinchester%2Fcarbonize/lists"}