You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-2Lines changed: 56 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,17 +54,58 @@ Example:
54
54
{% set events = craft.entries.section('events').isFuture('dateRangeFieldHandle', 'entryTypeHandle') %}
55
55
```
56
56
57
-
The plugin includes `isOnGoing()`, `isPast()`,`isNotPast()` and `isFuture()` query behaviors.
57
+
The plugin includes the following query behaviors:
58
+
-`isFuture()` - entries where the start date is in the future
59
+
-`isPast()` - entries where the end date is in the past
60
+
-`isNotPast()` - entries where the end date is in the future
61
+
-`isOnGoing()` - entries where the start date is in the past and the end date is in the future
62
+
-`startsAfterDate()` - entries where the start date is after the given date
63
+
-`endsBeforeDate()` - entries where the end date is before the given date
64
+
-`isDuringDate()` - entries where the date range overlaps with the given date or date range
65
+
-`isNotDuringDate()` - entries where the date range does not overlap with the given date or date range
66
+
58
67
The second argument passed should be the handle of the entry type you want to query.
59
68
60
-
You can optionally pass `true` as a third argument to the query to make it include events that happen today in future/past/onGoing queries.
69
+
You can optionally pass `true` as a third argument to `isFuture`, `isPast`, `isNotPast` and `isOnGoing` to include events that happen today.
70
+
71
+
The `startsAfterDate`, `endsBeforeDate`, `isDuringDate` and `isNotDuringDate` methods accept a date as the first argument, followed by the field handle and entry type handle:
72
+
73
+
```twig
74
+
{# Entries starting after a specific date #}
75
+
{% set events = craft.entries.section('events').startsAfterDate('2025-06-01', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}
76
+
77
+
{# Entries ending before a specific date #}
78
+
{% set events = craft.entries.section('events').endsBeforeDate('2025-12-31', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}
79
+
80
+
{# Entries overlapping with a single date #}
81
+
{% set events = craft.entries.section('events').isDuringDate('2025-06-15', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}
82
+
83
+
{# Entries overlapping with a date range #}
84
+
{% set events = craft.entries.section('events').isDuringDate('2025-06-01 => 2025-06-30', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}
85
+
86
+
{# Entries NOT overlapping with a date range #}
87
+
{% set events = craft.entries.section('events').isNotDuringDate('2025-06-01 => 2025-06-30', 'dateRangeFieldHandle', 'entryTypeHandle').all() %}
88
+
```
61
89
62
90
### Field values
63
91
When using the field in your template, you have access to both `start` and `end` properties, as well as:
64
92
-`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 ').
65
93
-`isPast`: returns `true` if the `end` property is past the current date & time.
66
94
-`isFuture`: returns `true` if the `start` property is ahead the current date & time.
67
95
-`isOnGoing`: returns `true` if the `start` property is past the current date & time *and* the `end` property is ahead of the current date & time.
96
+
-`isNotPast`: returns `true` if the `end` property is ahead of the current date & time.
97
+
-`startsAfterDate(date)`: returns `true` if the `start` property is after the given date.
98
+
-`endsBeforeDate(date)`: returns `true` if the `end` property is before the given date.
99
+
-`isDuringDate(date)`: returns `true` if the date range overlaps with the given date or date range.
100
+
-`isNotDuringDate(date)`: returns `true` if the date range does not overlap with the given date or date range.
101
+
102
+
The `isDuringDate` and `isNotDuringDate` methods accept a single date string, a date range string (using `=>` as separator), or an array with `start` and `end` keys:
103
+
104
+
```twig
105
+
{% if entry.dateRangeField.isDuringDate('2025-06-15') %}...{% endif %}
106
+
{% if entry.dateRangeField.isDuringDate('2025-06-01 => 2025-06-30') %}...{% endif %}
107
+
{% if entry.dateRangeField.isNotDuringDate('2025-07-01 => 2025-07-31') %}...{% endif %}
108
+
```
68
109
69
110
### `getFormatted()`
70
111
When using the ``getFormatted()`` function, you can pass paramters in 2 ways:
@@ -96,6 +137,19 @@ query{
96
137
}
97
138
}
98
139
```
140
+
141
+
The following GraphQL query arguments are also available: `startsAfterDate`, `endsBeforeDate`, `isDuringDate`, and `isNotDuringDate`.
0 commit comments