• Resolved GusGF

    (@gusgf)


    I created a date (i.e. date picker) field (event_date) using ACF. I’m using a query to fetch posts (events) after today’s date e.g. event_date>=date(‘Ymd) seems to work, pls ignore the syntax for brevity sake.

    In the ACF plugin when I look at the date format for event_date it’s format is dd/mm/yyyy as confirmed by the output of: echo get_field(‘event_date’); so is this being determined by the Return Format – The format returned via template functions option which I set when creating the ACF field?

    If so, why then when I run the query in a WP_Query with
    event_date>=date(‘dmY) my query fails to work correctly.
    event_date>=date(‘Ymd) my query works correctly.
    Again pls ignore the syntax for brevity sake. Are all dates coming from the database via queries in a default format i.e. ‘Ymd’?

    Can I also ask regarding the following get_field(‘event_date’, false, false), with the second boolean parameter if it’s set to true where is the formatting actually defined?

Viewing 1 replies (of 1 total)
  • Thread Starter GusGF

    (@gusgf)

    Okay so it looks like all dates queried from the WP DB directly will be in the format ‘Ymd’, like in a WP_Query query.
    Using the ACF functions e.g. get_field(‘event_date’, false, false)
    The second boolean parameter means…
    false: return a date in the WP DB format i.e. ‘Ymd’
    true: use the ACF’s return format set in the plugin

    • This reply was modified 4 years ago by GusGF.
Viewing 1 replies (of 1 total)
  • The topic ‘ACF date fields format questions’ is closed to new replies.