Jump to content

Datetime fields never returning any pages in selector


DrQuincy
 Share

Recommended Posts

I'm tearing my hair out here.

I have a Datetime field and whenever I use it in a selector — regardless of how I use it — no pages are returned.

I've:

  • Checked the field name is correct
  • Checked the field type is correct
  • Checked the selector is correct
  • Tried multiple date formats as the selector value

The field is called propertyEarliestDate.

So, if I do:

wire('pages')->find('template=property, propertyEarliestDate>=' . strtotime($myDate)); // $myDate definitely produces the correct Unix timestamp

I get an empty array. If I change it to:

wire('pages')->find('template=property, propertyEarliestDate<=' . strtotime($myDate));

I still get nothing — even though I have changed to selector to check the opposite. If I remove the selector all together it works. If I remove it, it returns some pages:

wire('pages')->find('template=property');

There are definitely pages with propertyEarliestDate populated.

Any ideas of anything I might be missing?

Thanks.

 

Link to comment
Share on other sites

Try this:

  • check the returned value of your datefield
  • check the strtotime value returned
  • don't do anything with your datefield value and just try that
  • convert it manually to a timestamp and try that - just to check
  • try if any of these work:
    $today = strtotime("today");
    $todayDate = date('d.m.Y', $today);
    $todayDateTime = date('d.m.Y H:i:s', $today);
     
  • last but not least: check the page data if there is anything in them, make a page dump to Tracy or var_dump()

 

That's how I narrow down issue like this.

  • Like 1
Link to comment
Share on other sites

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...