I am trying to filter my view by using a date range so that it shows all the activities for an event for which Activity Start >= Event End & Activity End <= Event Start
.
To do this I have set up a view to show all the activities with a contextual filter to allow the event dates to be accessed.
I added the 4 fields to my table: Activity Start, Activity End, Event Start, and Event End.
My $Row
data when adding a Global:PHP filter criteria now has the four variables accessible to carry out the comparison above.
- Activity Start: $Row->field_start_date_and_time
- Activity End: $Row->field_start_date_and_time_1
- Event Start: $Row->field_start_date_and_time_2
- Event End: $Row->field_start_date_and_time_3
I am using views_php 7.x-2.x-dev, which fixed the issue of $row
not populating.
I am trying to write the above comparison in PHP and I am not getting what I expected. (I thought this would be the easy bit; I have spent a long time getting this far.)
However, it appears that the date format is not being read correctly as it is not returning any result. I have done some research which would indicate it might need to be in Unix timecode to do the comparison accurately.
Is this correct? What does the code look like to do it?