<pre><code>$postDate = craft()-&gt;request-&gt;getPost('date');
$nextDay = new DateTime($postDate);    
'criteria' =&gt; [
    'section' =&gt; 'news',
    'date' =&gt; 'and,&gt;='.$postDate.',&lt;'.$nextDay-&gt;modify('+1 days')-&gt;format("Y-m-d"),
],
</code></pre>

CC BY-SA 3.0
2016-04-20T23:27:34.400Z
2016-04-20T23:27:34.400Z
Vitaliy  Badalov
<p>Something like this should work just for selecting a "day".</p>

<pre><code>'criteria' =&gt; [
    'section' =&gt; 'news',
    'customDateFieldHandle' =&gt; ['and', '&gt;='.DateTime::createFromString(craft()-&gt;request-&gt;getPost('date'))-&gt;format("Y-m-d").' 00:00:00', '&lt;='.$DateTime::createFromString(craft()-&gt;request-&gt;getPost('date'))-&gt;format("Y-m-d").' 23:59:59')];
],
</code></pre>

CC BY-SA 3.0
2016-04-07T19:10:25.983Z
you need to format the key and not the value
Vitaliy  Badalov
CC BY-SA 3.0
2016-04-07T19:30:09.913Z
I'm not following... why?
Brad Bell
CC BY-SA 3.0
2016-04-07T19:36:15.347Z
I need entries certain with days, "date" this is date field and returns the date and time, and I need only a day
Vitaliy  Badalov
CC BY-SA 3.0
2016-04-07T19:37:33.603Z
So you're searching against postDate?  Or a custom Date field?
Brad Bell
CC BY-SA 3.0
2016-04-07T19:40:03.147Z
is custom field
Vitaliy  Badalov
CC BY-SA 3.0
2016-04-08T18:03:05.813Z
Updated answer.
Brad Bell
CC BY-SA 3.0
2016-04-07T18:30:09.617Z
2016-04-08T18:01:52.063Z
2016-04-08T18:01:52.063Z
Brad Bell
<pre><code>'criteria' =&gt; [
    'section' =&gt; 'news',
    'date' =&gt; craft()-&gt;request-&gt;getPost('date')
],
</code></pre>

<p>How to make that worked like this:</p>

<pre><code>'criteria' =&gt; [
    'section' =&gt; 'news',
    'date-&gt;format("Y-m-d")' =&gt; craft()-&gt;request-&gt;getPost('date')
],
</code></pre>

<datetime><plugin-elementapi>
Format keys in Element API plugin
# Format keys in Element API plugin

(Asked by: username_0 on 2016-04-07)

'criteria' => [
    'section' => 'news',
    'date' => craft()->request->getPost('date')
],

How to make that worked like this:
'criteria' => [
    'section' => 'news',
    'date->format("Y-m-d")' => craft()->request->getPost('date')
],

**Tags:** datetime, plugin-elementapi

---

## 2 answers

### Answer by username_0 on 2016-04-20. Score: 2 | Accepted answer

$postDate = craft()->request->getPost('date');
$nextDay = new DateTime($postDate);    
'criteria' => [
    'section' => 'news',
    'date' => 'and,>='.$postDate.',<'.$nextDay->modify('+1 days')->format("Y-m-d"),
],


---

### Answer by username_1 on 2016-04-07. Score: 2

Something like this should work just for selecting a "day".
'criteria' => [
    'section' => 'news',
    'customDateFieldHandle' => ['and', '>='.DateTime::createFromString(craft()->request->getPost('date'))->format("Y-m-d").' 00:00:00', '<='.$DateTime::createFromString(craft()->request->getPost('date'))->format("Y-m-d").' 23:59:59')];
],

> **Comments:**
> **username_0**: you need to format the key and not the value  
> **username_1**: I'm not following... why?  
> **username_0**: I need entries certain with days, "date" this is date field and returns the date and time, and I need only a day  
> **username_1**: So you're searching against postDate?  Or a custom Date field?  
> **username_0**: is custom field  
> **username_1**: Updated answer.  

---

