PWaddict Posted June 1, 2018 Share Posted June 1, 2018 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 More sharing options...
PWaddict Posted June 1, 2018 Author Share Posted June 1, 2018 Using this it properly works: $today = time(); $news_posts = $page->children("limit=10, news_date<=$today"); Link to comment Share on other sites More sharing options...
BitPoet Posted June 1, 2018 Share Posted June 1, 2018 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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now