{"id":17275107,"url":"https://github.com/daun/processwire-datetime-carbon-format","last_synced_at":"2025-09-11T05:05:27.747Z","repository":{"id":56963103,"uuid":"305532894","full_name":"daun/processwire-datetime-carbon-format","owner":"daun","description":"Format ProcessWire Datetime fields as Carbon instances","archived":false,"fork":false,"pushed_at":"2021-06-19T17:02:56.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T09:41:24.771Z","etag":null,"topics":["carbon","datetime","processwire","processwire-modules"],"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/daun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-19T22:58:49.000Z","updated_at":"2021-01-24T22:08:23.000Z","dependencies_parsed_at":"2022-08-21T08:20:52.567Z","dependency_job_id":null,"html_url":"https://github.com/daun/processwire-datetime-carbon-format","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fprocesswire-datetime-carbon-format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fprocesswire-datetime-carbon-format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fprocesswire-datetime-carbon-format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fprocesswire-datetime-carbon-format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daun","download_url":"https://codeload.github.com/daun/processwire-datetime-carbon-format/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245667108,"owners_count":20652898,"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","processwire","processwire-modules"],"created_at":"2024-10-15T08:55:27.500Z","updated_at":"2025-09-11T05:05:27.737Z","avatar_url":"https://github.com/daun.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ProcessWire Datetime Carbon Format\r\n\r\n[![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/daun/processwire-datetime-carbon-format?color=97aab4\u0026label=version)](https://github.com/daun/processwire-datetime-carbon-format/releases)\r\n[![GitHub License](https://img.shields.io/github/license/daun/processwire-datetime-carbon-format?color=97aab4)](./LICENSE)\r\n\r\nFormat Datetime fields as [Carbon](https://carbon.nesbot.com/) instances.\r\n\r\n## Installation\r\n\r\nInstall the module using Composer. This will install Carbon as a child dependency.\r\n\r\n```bash\r\ncomposer require daun/datetime-carbon-format\r\n```\r\n\r\n\u003e ℹ️ Installation via the module directory will only work if you already have `nesbot/carbon` required from the project root.\r\n\r\n## Usage\r\n\r\nAll Datetime fields will now be formatted as Carbon instances instead of strings. Some examples of how to make use of this:\r\n\r\n```php\r\n// $page-\u003edate is a Datetime field\r\n// Output format: j/n/Y\r\n\r\necho $page-\u003edate;                    // 20/10/2027\r\necho $page-\u003edate-\u003eadd('7 days');     // 27/10/2027\r\necho $page-\u003edate-\u003eformat('l, F j');  // Monday, October 20\r\necho $page-\u003edate-\u003eyear;              // 2027\r\necho $page-\u003edate-\u003ediffForHumans();   // 28 minutes ago\r\n```\r\n\r\nConsult the [Carbon docs](https://carbon.nesbot.com/docs/) for details.\r\n\r\n## Notes\r\n\r\n### Frontend only\r\n\r\nThe ProcessWire admin expects datetime fields to be strings. That's why this module will only return Carbon instances on normal frontend page views.\r\n\r\n### Date output format\r\n\r\nWhen casting a Carbon instance to a string (usually when outputting the field in a template), the field's date output format will be respected.\r\n\r\n### Empty values\r\n\r\nEmpty date fields will be wrapped in a proxy object that silently \"swallows\" access to properties and methods without triggering an exception. That's because Carbon instances cannot be empty, i.e. created without a valid timestamp value.\r\n\r\nUse either the `timestamp` property or the `isset` accessor to see if a date has a value.\r\n\r\n```php\r\n// Date field with data\r\n$page-\u003edate-\u003etimestamp;    // 1778870000\r\n$page-\u003edate-\u003eisset;        // true\r\n$page-\u003edate-\u003eyear;         // 2027\r\n$page-\u003edate-\u003eformat('j');  // 20\r\n\r\n// Empty date field\r\n$page-\u003edate-\u003etimestamp;    // null\r\n$page-\u003edate-\u003eisset;        // null\r\n$page-\u003edate-\u003eyear;         // null\r\n$page-\u003edate-\u003eformat('j');  // null\r\n```\r\n\r\n### `carbon` API Variable\r\n\r\nThe module will create a pre-configured Carbon Factory and wire it into a new `carbon` API variable. This factory object can be used to create new Carbon instances, edit settings on it, etc.\r\n\r\n```php\r\n// Create a new Carbon instance\r\n$datetime = wire()-\u003ecarbon-\u003ecreateFromTimestamp($timestamp);\r\n```\r\n\r\n## Contributing\r\n\r\nPull requests are welcome. Please read the [Contributing Guidelines](./CONTRIBUTING.md).\r\n\r\n## License\r\n\r\n[MIT](./LICENSE)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Fprocesswire-datetime-carbon-format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaun%2Fprocesswire-datetime-carbon-format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Fprocesswire-datetime-carbon-format/lists"}