Jump to content

Where to find description of e.g. "-1 month" selectors?


MarcC
 Share

Recommended Posts

I tried "-1 day" on a whim and it worked, so I'm curious where I can find other selectors for date fields? I tried searching the forums, cheat sheet, and selectors page on the main site. Thanks!

Link to comment
Share on other sites

The rest are in Soma's head :D The guy knows everything  :P. Jokes aside, I think they are buried deep in PW code. I recall Soma saying when he was getting started he studied module code and looked in PW modules, etc.

Edit: Adding hopefully relevant links to collate date selector stuff in one place..

http://processwire.com/talk/topic/3290-sort-by-date-range/

http://processwire.com/talk/topic/2795-selector-with-dates-and-checkboxes/

http://processwire.com/talk/topic/2260-search-articles/ - Nice one! See post by Ryan

  • Like 2
Link to comment
Share on other sites

Direct quote from Ryan, taken from the first thread linked up there:

... you would just want your date to be in a format that is either a unix timestamp, or a string recognized by PHP strtotime().

So yes, that's how it works. Taking a quick look at source, when asked for a database query Datetime fieldtype simply converts selector value to date with format 'Y-m-d H:i:s', right after sanitizing it (in which process any non-timestamp value is parsed by strtotime()).

Digging through PW source is actually fun.. and also the only way to be 100% sure what's really going on and what kind of values will work :)

  • Like 5
Link to comment
Share on other sites

I have a feeling PW date selectors will obey stuff you can throw at PHP strtotime

Greetings,

As far as my experince goes, this is true. I use various date calls all the time in my ProcessWire sites, mixing ProcessWire and good old PHP to get what I need.

To add one more link to kongondo's list, Ryan and I posted a bit on this here:

http://processwire.com/talk/topic/2600-datetime-field-issue-with-dev/?p=25648

Thanks,

Matthew

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