title: Create display date range from two dates in ACF in Wordpress
body: <p>I have two Advanced Custom Fields datepicker fields in Wordpress – a starting date and a finishing date. These are in the back end, so that my client can add/edit posts and give them a date range. </p>
  
  <p>Dates below are given as dd/mm/yyyy (I'm Australian).</p>
  
  <p>I need to compare the two dates to come up with a nice date range for display on the front end. It needs to:</p>
  
  <ol>
  <li><p>Check to see whether the two dates are the same, in which case it should just output one date (e.g. start date is 20/7/2015, finish date is 20/7/2015, so output is <strong>20 July 2015</strong>).</p></li>
  <li><p>If the two dates are different but in the same month, output as dd – dd mm yyyy (e.g. start date is 10/3/2015, finish date is 25/3/2015, so output is <strong>10 – 25 March 2015</strong>).</p></li>
  <li><p>If the two dates are in different months but the same year, output as dd mm – dd mm yyyy (e.g. start date is 18/4/2015, finish date is 3/5/2015, so output is <strong>18 April – 3 May 2015</strong>).</p></li>
  <li><p>Finally, if the two dates are in different years, output as dd mm yyyy – dd mm yyyy (e.g. start date is 8/11/2015, finish date is 6/2/2016, so output is <strong>8 November 2015 – 6 February 2016</strong>).</p></li>
  </ol>
  
  <p>I can do 1 and 4 but lack the coding skills to manage 2 or 3.</p>
  
  <p>I'm very surprised I couldn't find this question on SO, so if I've overlooked a duplicate please point me in the right direction.</p>
  
  <p>Thanks.</p>