Page 1 of 1

Translate date to portuguese

Posted: Sat May 09, 2009 8:21 am
by Fudeba
/*************************************
Title: gbook
Version: 1.6
Author: Luciano Sturaro
Demo: http://www.py2bbs.qsl.br/gbook_test/gbook.php
Download:
Website:

Short description:
This script translate date to portuguese in any
webserver independent of php server language
configuration.

*************************************/

Look gbook.php at line 749

You look this:

Code: Select all

$added=date ("F j, Y");
Comment this line with // insert a one or two blank lines boot commented line and paste this code on line 750:

Code: Select all

$dia_num = date("w");// Dia da semana.

if($dia_num == 0){
$dia_nome = "Domingo";
}elseif($dia_num == 1){
$dia_nome = "Segunda";
}elseif($dia_num == 2){
$dia_nome = "Terça";
}elseif($dia_num == 3){
$dia_nome = "Quarta";
}elseif($dia_num == 4){
$dia_nome = "Quinta";
}elseif($dia_num == 5){
$dia_nome = "Sexta";
}else{
$dia_nome = "Sábado";
}

$dia_mes = date("d");// Dia do mês

$mes_num = date("m");// Nome do mês

if($mes_num == 01){
$mes_nome = "Janeiro";
}elseif($mes_num == 02){
$mes_nome = "Fevereiro";
}elseif($mes_num == 03){
$mes_nome = "Março";
}elseif($mes_num == 04){
$mes_nome = "Abril";
}elseif($mes_num == 05){
$mes_nome = "Maio";
}elseif($mes_num == 06){
$mes_nome = "Junho";
}elseif($mes_num == 07){
$mes_nome = "Julho";
}elseif($mes_num == 08){
$mes_nome = "Agosto";
}elseif($mes_num == 09){
$mes_nome = "Setembro";
}elseif($mes_num == 10){
$mes_nome = "Outubro";
}elseif($mes_num == 11){
$mes_nome = "Novembro";
}else{
$mes_nome = "Dezembro";
}
$ano = date("Y");// Ano

date_default_timezone_set("Brazil/East"); //Set time-zone to -3.00utc
$hora = date ("h:i a");

//$added=date ("F j, Y");
$added= $dia_nome.", ".$dia_mes." de ".$mes_nome." de ".$ano." - ".$hora;
This show date and time in this format:

Sábado, 09 de Maio de 2009 - 03:10 am

Thank's to Klemen Stirn for this nice guest book! :D

Posted: Sat May 09, 2009 9:25 am
by Klemen
Thanks for sharing this and the translation!

Great but I get the wrong time

Posted: Sun Jun 07, 2009 11:25 pm
by yoramdavid
Great translation.

I put 'H' instead of 'h' and got rid of the 'a' in the line "$hora = date ("h:i a"); " to have it on the 24 hour format.
We do not use am and pm in Portugal.

Being from Portugal, I replaced Brazil with Portugal or GMT and get one hour earlier than it is here.
We use time savings, is ther any way to solve that problem?

Thanks.