How do I restrict the date popup to 12 months from start date? I have a custom module where I set two date pop-ups. 

$form['set_start_date'] = array(
  '#type' =&gt; 'date',
  '#title' =&gt; t('set start date'),
  '#required' =&gt; TRUE,
);

$form['set_end_date'] = array(
  '#type' =&gt; 'date',
  '#title' =&gt; t('set end date'),
  '#required' =&gt; TRUE,
);


If I select 2017-04-12 as start date, the accepted end date should not be after 2018-04-12.  

How can I achieve this?
Following Method i used to restrict the date Pop-up to 12 months

$form['set_start_date'] = [
      '#title' =&gt; $this-&gt;t('START DATE '),
      '#type' =&gt; 'date',
      '#attributes' =&gt; array('type'=&gt; 'date', 'min'=&gt; '-12 months', 'max' =&gt; 'now' ),
      '#date_date_format' =&gt; 'd/m/Y',
    ];


 $form['set_end_date'] = [
      '#title' =&gt; $this-&gt;t('END DATE'),
      '#type' =&gt; 'date',
      '#attributes' =&gt; array('type'=&gt; 'date', 'min'=&gt; '-12 months', 'max' =&gt; 'now' ),
      '#date_date_format' =&gt; 'd/m/Y',
    ];


  $form['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Filter'),
    );

 return $form;
}