Home › Forums › General Issues › Query Time Picker field › Reply To: Query Time Picker field
Hi @robtje
Your selected format for the time field does not affect how it’s saved to the DB. From the documentation:
The value selected can be returned and displayed in different formats but will always be saved to the database as ‘hh-ii-ss’. This format matches the time part of any datetime value.
So you’ll need to change your query to that format as well 🙂
The time values are always stored as strings but if they’re strings that MYSQL recognizes as time/date you can query them as an interval in TIME format: https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
May I also suggest that you use WP_Query
instead of get_posts. When querying the database in WordPress, you should generally use a WP_Query object. WP_Query objects take a number of useful arguments and do things behind-the-scenes that other database access methods such as get_posts() do not.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.