 | Traduzir para o português os dados obtidos no servidor para hora e data Por: rchcarmo
| 02/11/09 |
Acho que consegui, mesmo sem ter maiores conhecimentos da linguagem PHP, traduzir do inglês para o português, as informações obtidas no servidor, através do arquivo reproduzido abaixo. Pode ter algum ou alguns erros, mas está funcionando. Veja no site: http://www.neloresantalucia.com
<?php
$hourdiff = "2"; // hours diff btwn server and local time
$dayofweek = date("l",time() + ($hourdiff * 3600));
$day = date("d",time() + ($hourdiff * 3600));
$month = date("F",time() + ($hourdiff * 3600));
$year = date("Y",time() + ($hourdiff * 3600));
$hours = date("H:i:s",time() + ($hourdiff * 3600));
$hora = date("H",time() + ($hourdiff * 3600));
if ($dayofweek == Monday)
$dayofweek = "Segunda-Feira";
elseif ($dayofweek == Tuesday)
$dayofweek = "Terça-Feira";
elseif ($dayofweek == Wednesday)
$dayofweek = "Quarta-Feira";
elseif ($dayofweek == Thursday)
$dayofweek = "Quinta-Feira";
elseif ($dayofweek == Friday)
$dayofweek = "Sexta-Feira";
elseif ($dayofweek == Saturday)
$dayofweek = "Sábado";
elseif ($dayofweek == Sunday)
$dayofweek = "Domingo";
{
if ($month == January)
$month = "janeiro";
elseif ($month == February)
$month = "fevereiro";
elseif ($month == March)
$month = "março";
elseif ($month == April)
$month = "abril";
elseif ($month == May)
$month = "maio";
elseif ($month == June)
$month = "junho";
elseif ($month == July)
$month = "julho";
elseif ($month == August)
$month = "agosto";
elseif ($month == September)
$month = "setembro";
elseif ($month == October)
$month = "outubro";
elseif ($month == November)
$month = "novembro";
elseif ($month == December)
$month = "dezembro";
}
{
if ($hora < 12)
print ("<div align=center><center><table border=0 width=800 cellspacing=12 cellpading=4 bgcolor=#0000FF><tr><th><font color=#FFFFFF face='Trebuchet MS' size=3>Bom dia! Hoje é $dayofweek, $day de $month de $year, e em Bonito/MS são: $hours hs.</font></th></tr></table></center></div>");
elseif ($hora < 18)
print ("<div align=center><center><table border=0 width=800 cellspacing=12 cellpading=4 bgcolor=#0000FF><tr><th><font color=#FFFFFF face='Trebuchet MS' size=3>Boa tarde! Hoje é $dayofweek, $day de $month de $year, e em Bonito/MS são: $hours hs.</font></th></tr></table></center></div>");
elseif ($hora < 24)
print ("<div align=center><center><table border=0 width=800 cellspacing=12 cellpading=4 bgcolor=#0000FF><tr><th><font color=#FFFFFF face='Trebuchet MS' size=3>Boa noite! Hoje é $dayofweek, $day de $month de $year, e em Bonito/MS são: $hours hs.</font></th></tr></table></center></div>");
}
?>