Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Arquivo de funções auxiliares
  4.  * @author Alessandro Kobs <contato@kobs.dev>
  5.  * @version 0.1
  6.  * @copyright GPL - 2020, KBS Desenvolvimento
  7.  * @package KbsHelpers
  8.  *
  9. **/
  10.  
  11.  
  12. if (!function_exists('brDateStringToDate')) {
  13.     function brDateStringToDate($string) {
  14.      
  15.         /**
  16.          *  Converter Data escrita no padrão BR (01 de Janeiro de 2020) para Internacional (01-01-2020)
  17.          *  @param String $dateString
  18.          *  @return String
  19.         **/
  20.  
  21.  
  22.         /**
  23.          *  Mantém a relação numérica e textual de meses
  24.          *  @name $definedMonths
  25.          *  @access private
  26.         **/
  27.         $definedMonths = [
  28.             'Janeiro'     =>     '01',
  29.             'Fevereiro'   =>     '02',
  30.             'Março'       =>     '03',
  31.             'Abril'       =>     '04',
  32.             'Maio'        =>     '05',
  33.             'Junho'       =>     '06',
  34.             'Julho'       =>     '07',
  35.             'Agosto'      =>     '08',
  36.             'Setembro'    =>     '09',
  37.             'Outubro'     =>     '10',
  38.             'Novembro'    =>     '11',
  39.             'Dezembro'    =>     '12'
  40.         ];
  41.  
  42.         $rawExplode = explode (' de ', $string);
  43.         $rawExplode[1] = $definedMonths[$rawExplode[1]];
  44.    
  45.         return implode('-',array_reverse($rawExplode));
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement