Alfredao

DateTimeStrategy.php

Feb 7th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.44 KB | None | 0 0
  1. <?php
  2. namespace Cadastro\Hydrator\Strategy;
  3.  
  4. use Zend\Stdlib\Hydrator\Strategy\DefaultStrategy;
  5.  
  6. class DateTimeStrategy extends DefaultStrategy
  7. {
  8.     /**
  9.      * Converte uma string para um objeto de DateTime
  10.      *
  11.      * @return \DateTime
  12.      */
  13.     public function hydrate($value)
  14.     {
  15.         if (is_string($value)) {
  16.             $value = new \DateTime($value);
  17.         }
  18.        
  19.         return $value->format('d/m/Y');
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment