Ronan Pellegrini
Ronan Pellegrini

Reputation: 13

API PHP - Filter item - by created_on

I am trying to filter my items by hour in a day but can't get expected result.

I only want the last two hours of a day and I am doing it by cron job for every 2 hours.

My code :

$attributes = array();
$attributes['sort_by'] = 'titre';
$attributes['sort_desc'] = true;
$attributes['filters'] = array("created_on" =>array("from" => "2016-08-09 13:00:00","to" => "2016-08-09 15:00:00"));
$attributes['limit'] = 10;
$attributes['offset'] = 0;
$attributes['remember'] = false; 
PodioItem::filter($myappid, $attributes, array());

This example should give me only one result, but it fails and gives me all items of the 2016-08-09 day. Is it possible to filter by date/time ?

Sorry for my English level

Thanks for reading my problem

Upvotes: 0

Views: 159

Answers (1)

Brad Smith
Brad Smith

Reputation: 335

Unfortunately, I believe what you are asking for is currently not possible with the API. I just checked our item filter handling, and we effectively flatten created_on filters to use "whole day" granularity. This means that even if you provide a higher-precision range of timestamps, anything beyond the date will be ignored.

So, in your example:

"from" => "2016-08-09 13:00:00", "to" => "2016-08-09 15:00:00"

Those parameters are altered within the API backend to look like:

"from" => "2016-08-09 00:00:00", "to" => "2016-08-09 23:59:59"

Upvotes: 2

Related Questions