Translate date to portuguese

Everything related to GBook PHP guestbook
Post Reply
Fudeba
Posts: 9
Joined: Sat May 09, 2009 8:01 am

Translate date to portuguese

Post 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
Last edited by Fudeba on Sun May 10, 2009 2:23 am, edited 2 times in total.
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Thanks for sharing this and the translation!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
yoramdavid
Posts: 3
Joined: Sun Jun 07, 2009 11:15 pm

Great but I get the wrong time

Post 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.
Yoram David
Post Reply