e0f Posted June 11, 2019 Share Posted June 11, 2019 Hi all guys, I'm in search to show pages created between a range. That's my code: $pages->find("template=test, id>1, sort=myFieldName, sort=-created, status=unpublished, (created>=2019-06-08, created<=2019-06-10"); The output is an array of pages with creation date between 8 June to 9 June. The correct output would be from 8 June to 10 June. How can I fix this? Thanks for support! Link to comment Share on other sites More sharing options...
e0f Posted June 11, 2019 Author Share Posted June 11, 2019 (edited) Sorry this is my code: $pages->find("template=test, id>1, sort=myFieldName, sort=-created, status=unpublished, (created>=2019-06-08, created<=2019-06-10)"); Edited June 11, 2019 by e0f Link to comment Share on other sites More sharing options...
Robin S Posted June 11, 2019 Share Posted June 11, 2019 Welcome to the forums @e0f ? When you use a datetime string (e.g. 2019-06-08) in a $pages->find() selector, the string gets converted to a timestamp behind the scenes via strtotime(). And if you only supply a date without any hours/minutes/seconds to strtotime() then 00:00:00 (midnight) is assumed. This means that in your selector you are actually searching for pages created between 2019-06-08 00:00:00 and 2019-06-10 00:00:00, so you will not find any events created after 00:00:00 on 10 June. So you can fix this by including a time in the second datetime string: $result = $pages->find("template=test, id>1, sort=myFieldName, sort=-created, status=unpublished, created>='2019-06-08', created<='2019-06-10 23:59:59'"); 21 hours ago, e0f said: (created>=2019-06-08, created<=2019-06-10) Also, you don't need parentheses around this portion of the selector. 1 1 Link to comment Share on other sites More sharing options...
e0f Posted June 13, 2019 Author Share Posted June 13, 2019 Thanks Robin, I never tought about hours and minutes! lol Btw, it works! So thanks for help me out! 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