Support

Account

Home Forums General Issues Extract and compare month from two date time picker fields Reply To: Extract and compare month from two date time picker fields

  • While this partially solves the problem (the date is now correctly displayed as I want it), all dates are shown as 1-1 January 1970.

    I know this has to do with the unix time stamp, which I encountered with a different go at cracking the code.

    Any thoughts on how to solve this ? Nearly there, I can feel it 🙂
    This is what I got at the moment

    <?php  
    $start_date = get_field('datum');
    $start_time = strtotime($start_date);
    $start_year = date('Y', $start_time);
    $start_month = date('F', $start_time);
    $start_day = date('j', $start_time);
    
    $end_date = get_field('eind_datum');
    $end_time = strtotime($end_date);
    $end_year = date('Y', $end_time);
    $end_month = date('F', $end_time);
    $end_day = date('j', $end_time);
    
    if (get_field('eind_datum') and get_field('datum') and ($end_month == $start_month)) {
      $display_date = $start_day.' - '.$end_day.' '.$end_month.' '.$end_year;
    } 
    elseif (get_field('eind_datum') and get_field('datum') and ($end_month != $start_month)) {
      $display_date = $start_day.' '.$start_month.' - '.$end_day.' '.$end_month.', '.$end_year;
    }
    else {
      $display_date = $start_day.' '.$start_month.' '.$start_year;
    }
    	
    echo $display_date;
    	 ?>