a-ok Posted April 21, 2018 Share Posted April 21, 2018 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 More sharing options...
PWaddict Posted April 21, 2018 Share Posted April 21, 2018 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 1 Link to comment Share on other sites More sharing options...
a-ok Posted April 21, 2018 Author Share Posted April 21, 2018 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 More sharing options...
PWaddict Posted April 21, 2018 Share Posted April 21, 2018 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 More sharing options...
a-ok Posted April 21, 2018 Author Share Posted April 21, 2018 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... Link to comment Share on other sites More sharing options...
PWaddict Posted April 21, 2018 Share Posted April 21, 2018 If it returns anything it will probably be the current date/time as a UNIX timestamp. Link to comment Share on other sites More sharing options...
LostKobrakai Posted April 22, 2018 Share Posted April 22, 2018 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') 2 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