Support

Account

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.