note 31176 added to function.date
| From: | barao_d_submundo at rack1 dot php dot net | Date: | Sat, 12 Apr 2003 02:27:04 +0000 |
| Subject: | note 31176 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46531@lists.php.net to get a copy of this message | ||
I'm a beginer but i'm still making my way through php with a great help
from the coments left in the site, so I would like to contribute with
my share this time with this simple code that allows anyone to translate
to their language a simple phrase like:
"Domingo, 25 de Dezembro de 2003"
(Sunday, 25th December of 2003)
This script is made for portuguese but can be easily generalized
to any other language.
<?
//This is an array with the 7 days of the week
$semana=
array("Domingo","Segunda-feira","Terça-feira","Quarta-feira",
"Quinta-feira","Sexta-feira","Sábado");
//This makes an array with the 12 months of the year
//Mind that the first collumn is in blank to just because
//the format in php to represent months numerically is from 1 to 12, so
//the $meses[0] is in blank
//and will never be used.
$meses=array("
","Janeiro","Fevereiro","Março","Abril","Maio",
"Junho","Julho","Agosto","Setembro",
"Outubro","Novembro","Dezembro");
//Day of the month
$dia_mes=date("j");
//Day of the week
$dia_semana=date("w");
//Month of the year
$mes_ano=date("n");
//The year :P
$ano=date("Y");
//and finally it's echo
echo $semana[$dia_semana].', '.$dia_mes.' de '.$meses[$mes_ano].' de
'.$ano;
?>
I hope this can be usefull to other newbies, since i bet that most advanced
users might know some other shorter way of doing it, but much more complicated.
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+31176
http://master.php.net/manage/user-notes.php?action=delete+31176
http://master.php.net/manage/user-notes.php?action=reject+31176