Created
March 17, 2016 16:21
-
-
Save helmerdavila/1561208493f832af4cc6 to your computer and use it in GitHub Desktop.
Helper para fecha a español
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('formato_fecha')) { | |
function formato_fecha($time = null) | |
{ | |
$dias = ["Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado"]; | |
$meses = [ | |
"Enero", | |
"Febrero", | |
"Marzo", | |
"Abril", | |
"Mayo", | |
"Junio", | |
"Julio", | |
"Agosto", | |
"Septiembre", | |
"Octubre", | |
"Noviembre", | |
"Diciembre", | |
]; | |
if (!is_null($time)) { | |
$time = strtotime($time); | |
echo $dias[date('w', $time)] . " " . date('d', $time) . " de " . $meses[date('n', $time) - 1] . " del " . date('Y', $time); | |
} else { | |
echo $dias[date('w')] . " " . date('d') . " de " . $meses[date('n') - 1] . " del " . date('Y'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment