Jump to content

Return events from today and in future using date field


a-ok
 Share

Recommended Posts

What does a date, chosen in a date field, mark as the UNIX timestamp? For example, if I chose 21st April 2018 as my date; is the UNIX timestamp it returns 23:59:59 on the 21st April? Or is it 0:00:00 21st April? Or what does it depend on?

I want to return events that are on today or after but when using a page selector of “template=detail, detail_date>=$today” and $today is declared as strtotime(“now”); it won’t be returned but I’m having a hard time working out what $today should be? Midnight today plus 23:59:59?

Link to comment
Share on other sites

1 hour ago, PWaddict said:

Don't delcare $today. To get today and future events you have to remove the $ from today on the selector:


template=detail, detail_date>=today

 

Thanks! I’ve used this before but in some circumstances you can’t use it. Do you know ‘today’ is outputting?

Link to comment
Share on other sites

1 hour ago, oma said:

Thanks! I’ve used this before but in some circumstances you can’t use it. Do you know ‘today’ is outputting?

Sorry but I don't understand your question. I'm using >=today in my date's field on selector in order to get today and future events and it's working fine.

Link to comment
Share on other sites

On 21.4.2018 at 11:35 PM, oma said:

You can’t use it in filters() I believe etc... only in a find selector which’ll be fine but I’m curious to find out what “today” is actually returning – as a UNIX timestamp... 

You're correct that data string values are only translated for find queries, but not runtime selectors. But processwire just uses `strtotime` so you can easily use that on your own:

strtotime('today')

 

  • Like 2
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...