<?php
function fecha ()
{
$vect=getdate();
$vect_dia=array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
$vect_mes=array("Diciembre","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre");
return $vect_dia[$vect[wday]].", ".$vect[mday]." de ".$vect_mes[$vect[mon]]." de ".$vect[year];
}
echo fecha()."<br>";
?>
Refactorings
No refactoring yet !
Mlopez
December 22, 2007, December 22, 2007 02:56, permalink
you can remove the "hoy es".
i'm a little rusty on my spanish but it works.
http://www.mspy2.com/spanish.php - a working test.
we will find out on january 1st if it completely works.
<?php
function fecha ()
{
$vect=getdate();
$vect_dia=array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
$vect_mes=array("empty","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
return $vect_dia[$vect[wday]].", ".$vect[mday]." de ".$vect_mes[$vect[mon]]." de ".$vect[year];
}
echo "Hoy es ".fecha()."<br>";
?>
Caco_Patane
March 18, 2009, March 18, 2009 20:31, permalink
In the line containing the 'return' statement the indexes of the $vect array are referenced incorrectly as constants and must be referenced as string. For example, instead of $vect[wday] you must use $vect['mday'] or PHP will comply.
return $vect_dia[$vect['wday']].", ".$vect['mday']." de ".$vect_mes[$vect['mon']]." de ".$vect['year'];
hi, I'm a student and i create this function, he print an spanish format date.