Jump to content

[SOLVED] Problem with today selector???


PWaddict
 Share

Recommended Posts

Using the following selector I should be able to get today's and past posts but I'm only getting the past ones.

$news_posts = $page->children("limit=10, news_date<=today");

If I change the operator to >= then I get today's and upcoming posts but why the <= doesn't display today's posts too?

Link to comment
Share on other sites

In the database, datetime fields have a time part that is set to the current time when saving a new value for a date only field. "today" is interpolated by PHP's strtotime function to 00:00:00 of today's date, so <= will only match articles posted exactly at midnight. You probably want to use

$news_posts = $page->children("limit=10, news_date<tomorrow");

instead.

  • Thanks 1
Link to comment
Share on other sites

  • PWaddict changed the title to [SOLVED] Problem with today selector???

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...