Limit ElementAPI results with custom date/time field
After some exploration and trial and error, I was able to find a solution. Ultimately there are two problems:


startDateTime, endDateTime and php’s date() function were not returning the same timezone date &amp; time.
The correct formatting for matching multiple values needs to be in an array.




The fix:

At the top of my elementapi.php file I added this line to make sure php’s date() function returns the same timezone craft has been set to in the admin config.

date_default_timezone_set(craft()-&gt;timezone);

Then I reformatted my criteria settings as such:

'criteria' =&gt; [
    'section' =&gt; 'mySection', 
    'type' =&gt; 'mySectionType',
    'startDateTime' =&gt; ['&lt;=' . date("Y-m-d H:i:s.u"), ':empty:'],
    'endDateTime' =&gt; ['&gt;=' . date("Y-m-d H:i:s.u"), ':empty:']
],