Is there any way to achieve relative date in Views FILTER CRITERIA?
I need a date between 'first day of' and 'last day of'.
Views Contextual Range Filter Module does not work on Drupal 8.4.x.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
The standard date Views filters in Drupal 8 have two options:
The first is an absolute date. The second is a relative date string (I don't know why this is called an offset date).
So, add a filter, choose 'offset' as an option, and then enter your relative date. These work for simple comparisons, and between/not between.
At runtime, the value you entered will be parsed by
strtotime(); any date-like string that it will accept can be used. This means that it will be dynamic and always be relative to when the view is executed and not when the view was created. php|architect’s Guide to Date and Time Programming has a nice appendix in it about what are parsable values (and some of the quirks).
Keep in mind that you may need to adjust the cache rules for the view to prevent stale data from being displayed. Also, there is a bug1 regarding time zone handling that has not been committed to core yet, which may result in some weirdness.
1 Barring unforeseen problems, this will be fixed in Drupal 8.5.0.