...

View Full Version : Formating month in date()



matak
08-03-2007, 02:45 AM
Script to show file creation date is as follows


$filename = "file.txt";
if (file_exists($filename)) {
echo "<p class=\"ftime\">Dodano: " . date ("d F Y H:i:s.", filemtime($filename))."</p>";
}

it outputs something like

01 January 2001

How can i replace january with month in my language. i searched but couldn't find the answer.

CFMaBiSmAd
08-03-2007, 04:25 AM
http://php.net/strftime

matak
08-03-2007, 06:27 PM
I still cant figure this one..
If someone made a script to translate Month names into their own language, please share, or at least gimme a hint. I can't understand one on php.net page..

Thank you

mic2100
08-14-2007, 04:08 PM
<?
if (eregi("functions_date.php",$PHP_SELF)) { // If accessed directly,
header("Location:../index2.php"); // Sends you to your index page (mine is outside my functions dir.)
die();
}
?>
<?
function conv_fecha($dia_larga) // this is the Day converter, mines does it to spanish
{
switch($dia_larga){
case "Monday":
$dia_larga="Lunes";
return $dia_larga;
break;
case "Tuesday":
$dia_larga="Martes";
return $dia_larga;
break;
case "Wednesday":
$dia_larga="Miercoles";
return $dia_larga;
break;
case "Thursday":
$dia_larga="Jueves";
return $dia_larga;
break;
case "Friday":
$dia_larga="Viernes";
return $dia_larga;
break;
case "Saturday":
$dia_larga="Sabado";
return $dia_larga;
break;
case "Sunday":
$dia_larga="Domingo";
return $dia_larga;
break;
}}
?>
<?
function conv_mes($mes) // this is the Month converter, mines does it to spanish
{
switch($mes){
case 1:
$mes="Enero";
return $mes;
break;
case 2:
$mes="Febrero";
return $mes;
break;
case 3:
$mes="Marzo";
return $mes;
break;
case 4:
$mes="Abril";
return $mes;
break;
case 5:
$mes="Mayo";
return$mes;
break;
case 6:
$mes="Junio";
return $mes;
break;
case 7:
$mes="Julio";
return $mes;
break;
case 8:
$mes="Agosto";
return $mes;
break;
case 9:
$mes="Septiembre";
return $mes;
break;
case 10:
$mes="Octubre";
return $mes;
break;
case 11:
$mes="Noviembre";
return $mes;
break;
case 12:
$mes="Diciembre";
return $mes;
break;
}}
?>
<?
$dia_larga= date("l");
$dia=date("j");
$mes=date("n");
$year=date("Y");
// SENDS THE DAY AND MONTH TO THE FUNCTIONS TO BE CONVERTED
$dia_larga=conv_fecha($dia_larga);
$mes=conv_mes($mes);
?>


i found this on another forum hopefully this will do what you want. if you want to convert into different languages you will have to enter them into this.

Thanks to carrzco Date Converter (http://www.codewalkers.com/c/a/Date-Time-Code/Date-converter-to-your-language/)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum