I want to show yesterday's posts on a block with views. So I added two date filters. They should be:

<today midnight

>yesterday midnight

(-1 day is not ok for me because it spans exactly 24 hours back)

According to the manual: http://php.net/manual/en/datetime.formats.relative.php I added the two filters as: Less than "today" (I also tried less than "midnight" or "today 00:00") Greater than "yesterday" (I also tried greater than "yesterday 00:00")

But they are all showing the items from yesterday and today together.

Is there a way to show items from yesterday 00:00 to yesterday 23:59 ?

3 Answers 3


I ended up using contextual filter instead of filters. I added:

Content: Created date

Provide default value - php code

return date("d", strtotime("-1 day"));

I had the same problem, but unfortunately for me, the field didn't appear in contextual filters, so I still had to use the normal date filter. This worked perfectly for me:

date filter timestamp configuration example


I always end up forgetting I need to have "two filters" in order to accomplish this... At least that's what works for me.

I just got done messing with it trying to show some posts from yesterday and came up with:

Content: Authored on (>= yesterday)
Content: Authored on (<= today)

I think the OP had the filters reversed and that's why they weren't working. Since the filters work top to bottom, "today" was filtered first so there was no real end time to capture.

Love the "is between" method suggested tho. That's boss.

Update: On a side note to get the same result as the "is between" suggestion, this should also work:

Is Between:

Min = yesterday
Max = today -1 second

Keep in mind, yesterday is the exact same thing as yesterday midnight


Here's a great way to test the strototime:


And on a final note, Drupal 8 as of 8.7.7 has a bug where the datetime does not properly execute the right strtotime, resulting in "yesterday" actually being "now -24 hours" instead of "yesterday 00:00". See the following issue for a patch:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.