Support

Account

Home Forums ACF PRO Multiple Date Ranges – Date Picker

Helping

Multiple Date Ranges – Date Picker

  • Hi,

    Is it possible to create If – else statements for a pre-defined range of dates using the date field ?

    Rough gist of what I want to do –

    if in Date Range 1 - 'Spring' = 'January - March' > echo = 'it's spring'
    
    if in Date Range 2 - 'Summer' = 'April - August' > echo = 'it's summer'
    
    if Date in Range 3 - 'Autumn' = 'September - December' > echo = 'it's autumn'
  • The exact details of what you do would depend on the settings of the field.

    Something like

    
    // depends on acf returning a date format compatible with PHP date functions
    $month = date('n', strtotime(get_field('date_field_name')));
    if ($month >= 1 && $month <= 3) {
      // it's spring
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.