Browse Source

Funções para converter stftime para DateTime

ajuste_divisao
bruno 1 year ago
parent
commit
3194616888
  1. 28
      include/util/util.php

28
include/util/util.php

@ -2462,7 +2462,8 @@ function strftime_( $format, $timestamp = null ){
/* tratar string */ /* tratar string */
$str_converted = convert_format_strftime( $format );
return $date_immutable->format( $str_converted );
} }
@ -2479,19 +2480,19 @@ function convert_format_strftime( $format ){
/* formato strftime */ /* formato strftime */
$patterns = array( $patterns = array(
/* day */ /* day */
'%a', '%A', '%d','%e', '%j','%u', '%w', '/%a/', '/%A/', '/%d/','/%e/', '/%j/','/%u/', '/%w/',
/* Week */ /* Week */
'%U', '%V','%W', '/%U/', '/%V/','/%W/',
/* Month */ /* Month */
'%b','%B', '%h','%m' , '/%b/','/%B/', '/%h/','/%m/',
/* Year */ /* Year */
'%C','%g', '%G','%y', '%Y', '/%C/','/%g/', '/%G/','/%y/', '/%Y/',
/* Time */ /* Time */
'%H', '%k', '%I', '%l', '%L', '%M', '%p', '%P', '%r', '%R', '%S', '/%H/', '/%k/', '/%I/', '/%l/', '/%M/', '/%p/', '/%P/', '/%r/', '/%R/', '/%S/',
'%T','%X', '%z','%Z' , '/%T/','/%X/', '/%z/','/%Z/',
/* Time and Date Stamps */ /* Time and Date Stamps */
'%c','%D', '%F','%s', '%x','%n', '/%c/','/%D/', '/%F/','/%s/', '/%x/','/%n/',
'%t','%%' '/%t/','/%%/'
); );
/* valores similares de strftime /* valores similares de strftime
@ -2508,17 +2509,14 @@ function convert_format_strftime( $format ){
/* Year */ /* Year */
'', 'y', 'o', 'y', 'o', '', 'y', 'o', 'y', 'o',
/* Time */ /* Time */
'H', 'G', 'h', 'g', 'g', 'i', 'A', 'a', '', '', 'i', 'H', 'G', 'h', ' g', 'i', 'A', 'a', '', '', 's',
'', '', '', '', '', '', '', '',
/* Time and Date Stamps */ /* Time and Date Stamps */
'','', '','', '','', '','', '','', '','',
' ','\%' ' ','%'
); );
return preg_replace( $patterns, $replacements, $format );
echo preg_replace( $patterns, $replacements, $format );
} }

Loading…
Cancel
Save