title: How to add a custom hydrator strategy for doctrine Date hydrator
body: <p>I have a form which contains 3 field of type text and with a Date validator.</p>
  
  <p>This code is in a fieldset using doctrine hydrator (related to a doctrine entity)</p>
  
  <pre><code>$this-&gt;add(
          array(
              'name' =&gt; 'endDate',
              'type' =&gt; 'Zend\Form\Element\Text',
              'options' =&gt; array(
                  'label' =&gt; 'end_date_label',
                  'label_attributes' =&gt; array(
                      'class'  =&gt; 'control-label col-xs-3'
                  ),
              ),
              'attributes' =&gt; array(
                  'class' =&gt; 'form-control col-xs-3 datepicker-end-date',
              )
          )
      );
  
  
  'endDate' =&gt; array(
          'required'   =&gt; true,
          'allow_empty' =&gt; false,
          'filters'    =&gt; array(
              array('name' =&gt; 'StripTags'),
              array('name' =&gt; 'StringTrim'),
          ),
          'validators' =&gt; array(
              array(
                  'name' =&gt; 'Date',
                  'options' =&gt; array(
                      'format' =&gt; 'd/m/Y',
                  ),
              ),
          ),
      ),
  </code></pre>
  
  <p>I working with french date format. When i valid the form if i change the format to m/d/Y it's working but when my form is not valid, my date picker get the wrong date (month and days are inversed).</p>
  
  <p>What i want is to valid a french date format, and save into Database a date in m/d/Y format.</p>
  
  <p>With this format i get the error :</p>
  
  <pre><code>DateTime::__construct(): Failed to parse time string (29/04/2015) at position 0 (2): Unexpected character
  </code></pre>
  
  <p>I saw many post on Stack talking about custom strategy for doctrine hydration but i didn't understand them. What i'm supposed to do step by step ?</p>
  
  <p>I tried to add a strategy for my field endDate but it's never called...This code is in the fieldset class just before my fields declaration :</p>
  
  <pre><code>$this-&gt;setHydrator(new DoctrineHydrator($this-&gt;getObjectManager(), 'TodoList\Entity\TodoQuestion'))
              -&gt;setObject(new TodoQuestion());
          $this-&gt;getHydrator()-&gt;addStrategy('endDate', new \Application\Strategy\DateTimeStrategy());
  </code></pre>
  
  <p>And my Datetime strategy implements strategy interface.</p>
  
  <pre><code>&lt;?php
  
  namespace Application\Strategy;
  
  use Zend\Stdlib\Hydrator\Strategy\StrategyInterface;
  
  class DateTimeStrategy implements StrategyInterface
  {
      public function hydrate($value)
      {
          if (is_string($value)) {
              $value = new DateTime($value);
          }
          return $value-&gt;format('d/m/Y');
      }
  
      public function extract($value)
      {
          return;
      }
  }
  </code></pre>
  
  <p>If someone can explain with details what i'm doing wrong and help me to understand this whole thing..</p>