Skip to content

Instantly share code, notes, and snippets.

@helmerdavila
Created March 17, 2016 16:21
Show Gist options
  • Save helmerdavila/1561208493f832af4cc6 to your computer and use it in GitHub Desktop.
Save helmerdavila/1561208493f832af4cc6 to your computer and use it in GitHub Desktop.
Helper para fecha a español
<?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