{"id":30228516,"url":"https://github.com/studioespresso/craft-date-range","last_synced_at":"2026-02-22T17:24:50.247Z","repository":{"id":35387367,"uuid":"214519432","full_name":"studioespresso/craft-date-range","owner":"studioespresso","description":"Date range field for Craft CMS","archived":false,"fork":false,"pushed_at":"2026-02-21T19:44:29.000Z","size":197,"stargazers_count":12,"open_issues_count":13,"forks_count":8,"subscribers_count":1,"default_branch":"develop-v5","last_synced_at":"2026-02-22T00:45:30.346Z","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/studioespresso.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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,"zenodo":null},"funding":{"github":["janhenckens"]}},"created_at":"2019-10-11T20:01:29.000Z","updated_at":"2026-02-21T19:44:33.000Z","dependencies_parsed_at":"2024-11-28T19:31:50.272Z","dependency_job_id":"82b460c0-cd60-4a79-924d-e54cfd89ebd5","html_url":"https://github.com/studioespresso/craft-date-range","commit_stats":{"total_commits":81,"total_committers":5,"mean_commits":16.2,"dds":"0.49382716049382713","last_synced_commit":"2d72e72c5394cb223956c40b75ebe3668f5bfcb3"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/studioespresso/craft-date-range","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studioespresso%2Fcraft-date-range","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studioespresso%2Fcraft-date-range/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studioespresso%2Fcraft-date-range/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studioespresso%2Fcraft-date-range/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/studioespresso","download_url":"https://codeload.github.com/studioespresso/craft-date-range/tar.gz/refs/heads/develop-v5","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studioespresso%2Fcraft-date-range/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29720561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T15:10:41.462Z","status":"ssl_error","status_checked_at":"2026-02-22T15:10:04.636Z","response_time":110,"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":[],"created_at":"2025-08-14T19:54:59.367Z","updated_at":"2026-02-22T17:24:50.238Z","avatar_url":"https://github.com/studioespresso.png","language":"PHP","funding_links":["https://github.com/sponsors/janhenckens"],"categories":[],"sub_categories":[],"readme":"# Date Range field for Craft CMS\n\nWhat is says on the tin 🙂. This field gives you a start and end date in 1 field.\n\n\u003cimg src=\"https://www.studioespresso.co/assets/date-range-github-banner.png\"\u003e\n\n## Requirements\n\nThis plugin requires Craft CMS 3, 4 or 5.\n\n## Installation\n\nTo install the plugin, follow these instructions.\n\n1. Open your terminal and go to your Craft project:\n\n        cd /path/to/project\n        composer require studioespresso/craft-date-range\n        ./craft install/plugin date-range\n\n## Settings\nThe following options can be set on the field:\n- Show a start time field\n- Show an end time field\n- End date should be after or later thand the start date\n\nWhen the field is set to required, both start \u0026 end date (and if enabled time) will be required. \n\n## Default time values\nSince a PHP ``DateTime`` object also has a time value, wether you entered on or not (or wether you have to option enabled to show the fields or not), the plugin tries to be smart  in which time values get saved.\n\nWhen you enable either or both time fields, that value will off course be safed. For fields that don't have time options set, ``00:00:00`` will get saved.\n\n## Upgrading to Craft 5\nWith Craft 5 comes multi-instance support (fields can be used multiple times in the same layout) and this adds a bit of complexity for the Date Range plugin.\nIn the query behaviour, you'll need to add the handle of the entry type you're trying to query as a second argument.\n\n````twig\n// Craft 4\n{% set events = craft.entries.section('events').isFuture('dateRangeFieldHandle')  %}\n\n// Craft 5\n{% set events = craft.entries.section('events').isFuture('dateRangeFieldHandle', 'entryTypeHandle')  %}\n````\n\n## Templating\n\n### Element queries\n⚠️ Using date range fields in your entry queries is possible but requires the site to be running **MySQL 5.7 or later** or **PostgreSQL 9.3 or later**.\n\nExample:\n\n```twig\n{% set events = craft.entries.section('events').isFuture('dateRangeFieldHandle', 'entryTypeHandle')  %}\n```\n\nThe plugin includes the following query behaviors:\n- `isFuture()` - entries where the start date is in the future\n- `isPast()` - entries where the end date is in the past\n- `isNotPast()` - entries where the end date is in the future\n- `isOnGoing()` - entries where the start date is in the past and the end date is in the future\n- `startsAfterDate()` - entries where the start date is after the given date\n- `endsBeforeDate()` - entries where the end date is before the given date\n- `isDuringDate()` - entries where the date range overlaps with the given date or date range\n- `isNotDuringDate()` - entries where the date range does not overlap with the given date or date range\n\nThe second argument passed should be the handle of the entry type you want to query.\n\nYou can optionally pass `true` as a third argument to `isFuture`, `isPast`, `isNotPast` and `isOnGoing` to include events that happen today.\n\nThe `startsAfterDate`, `endsBeforeDate`, `isDuringDate` and `isNotDuringDate` methods accept a date as the first argument, followed by the field handle and entry type handle:\n\n```twig\n{# Entries starting after a specific date #}\n{% set events = craft.entries.section('events').startsAfterDate('2025-06-01', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}\n\n{# Entries ending before a specific date #}\n{% set events = craft.entries.section('events').endsBeforeDate('2025-12-31', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}\n\n{# Entries overlapping with a single date #}\n{% set events = craft.entries.section('events').isDuringDate('2025-06-15', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}\n\n{# Entries overlapping with a date range #}\n{% set events = craft.entries.section('events').isDuringDate('2025-06-01 =\u003e 2025-06-30', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}\n\n{# Entries NOT overlapping with a date range #}\n{% set events = craft.entries.section('events').isNotDuringDate('2025-06-01 =\u003e 2025-06-30', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}\n```\n\n### Field values\nWhen using the field in your template, you have access to both `start` and `end` properties, as well as:\n- `getFormatted()`: which optionally accepts a date(time) format (eg: 'd/m/Y') as the first parameter and a seperator string as the second (eg: ' until ').\n- `isPast`: returns `true` if the `end` property is past the current date \u0026 time.\n- `isFuture`: returns `true` if the `start` property is ahead the current date \u0026 time.\n- `isOnGoing`: returns `true` if the `start` property is past the current date \u0026 time *and* the `end` property is ahead of the current date \u0026 time.\n- `isNotPast`: returns `true` if the `end` property is ahead of the current date \u0026 time.\n- `startsAfterDate(date)`: returns `true` if the `start` property is after the given date.\n- `endsBeforeDate(date)`: returns `true` if the `end` property is before the given date.\n- `isDuringDate(date)`: returns `true` if the date range overlaps with the given date or date range.\n- `isNotDuringDate(date)`: returns `true` if the date range does not overlap with the given date or date range.\n\nThe `isDuringDate` and `isNotDuringDate` methods accept a single date string, a date range string (using `=\u003e` as separator), or an array with `start` and `end` keys:\n\n```twig\n{% if entry.dateRangeField.isDuringDate('2025-06-15') %}...{% endif %}\n{% if entry.dateRangeField.isDuringDate('2025-06-01 =\u003e 2025-06-30') %}...{% endif %}\n{% if entry.dateRangeField.isNotDuringDate('2025-07-01 =\u003e 2025-07-31') %}...{% endif %}\n```\n\n### `getFormatted()`\nWhen using the ``getFormatted()`` function, you can pass paramters in 2 ways:\n1) a date format and a separator string (eg: ``entry.dateRangeHandle.formatted(\"d/m/Y Hi\", \"until\"|t)``)  \n2) an array with a ``date`` and a ``time`` key and a separator string (eg: ``entry.dateRangeHandle.formatted({ date: 'd/m/Y', time: 'H:i:s'}, 'tot'|t)``)\n\nWith this second option, the field can output date and time seperatly and when the start and end dates are the same, it will only ouput one, using the separate time formates for the start and end times (eg `` 30/04/2020 11:00 until 16:00`` )\n\n## GraphQL\nThe field has full support for Craft's GraphQL api, which was added in Craft CMS 3.3\nYou have access to the same properties as you do in Twig, and you can also use Craft's ``@formatDateTime`` to change the date formats.  \n\n```graphql\nquery{\n  entries(\n   section: \"events\",\n   isFuture: [\"dateRangeFieldHandle\", true]\n  ) {\n    title\n    ... on events_events_Entry {\n      dateRangeFieldHandle {\n        start\n        end @formatDateTime(format: \"d M Y\")\n        isPast\n        isOnGoing\n        isFuture\n      }\n    }\n  }\n}\n```\n\nThe following GraphQL query arguments are also available: `startsAfterDate`, `endsBeforeDate`, `isDuringDate`, and `isNotDuringDate`.\n\n```graphql\nquery{\n  entries(\n   section: \"events\",\n   isDuringDate: [\"2025-06-01 =\u003e 2025-06-30\", \"dateRangeFieldHandle\", \"entryTypeHandle\"]\n  ) {\n    title\n  }\n}\n```\n----\n\nBrought to you by [Studio Espresso](https://www.studioespresso.co)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudioespresso%2Fcraft-date-range","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstudioespresso%2Fcraft-date-range","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudioespresso%2Fcraft-date-range/lists"}