note 46489 deleted from function.date by aidan
| From: | aidan@php.net | Date: | Tue, 26 Oct 2004 00:41:16 +0000 |
| Subject: | note 46489 deleted from function.date by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79103@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster at joksnet dot com dot ar
----
here is to translate de function date. it's translate the format strings: l, M, D and F.
<?php
function translate_date( $format, $timestamp )
{
// This is for Spanish, change to your languaje.
$wdays = array("Domingo", "Lunes", "Martes", "Miercoles",
"Jueves", "Viernes", "Sabado");
$months = array(1 => "Enero", "Febrero", "Marzo",
"Abril", "Mayo", "Junio", "Julio", "Agosto",
"Septiembre", "Octubre", "Noviembre", "Diciembre");
$replace_wdays = array(
date("l", mktime(0, 0, 0, 11, 10, 1991)) => $wdays[0],
date("l", mktime(0, 0, 0, 11, 11, 1991)) => $wdays[1],
date("l", mktime(0, 0, 0, 11, 12, 1991)) => $wdays[2],
date("l", mktime(0, 0, 0, 11, 13, 1991)) => $wdays[3],
date("l", mktime(0, 0, 0, 11, 14, 1991)) => $wdays[4],
date("l", mktime(0, 0, 0, 11, 15, 1991)) => $wdays[5],
date("l", mktime(0, 0, 0, 11, 16, 1991)) => $wdays[6]
);
$replace_short_wdays = array(
date("D", mktime(0, 0, 0, 11, 10, 1991)) => substr($wdays[0], 0, 3),
date("D", mktime(0, 0, 0, 11, 11, 1991)) => substr($wdays[1], 0, 3),
date("D", mktime(0, 0, 0, 11, 12, 1991)) => substr($wdays[2], 0, 3),
date("D", mktime(0, 0, 0, 11, 13, 1991)) => substr($wdays[3], 0, 3),
date("D", mktime(0, 0, 0, 11, 14, 1991)) => substr($wdays[4], 0, 3),
date("D", mktime(0, 0, 0, 11, 15, 1991)) => substr($wdays[5], 0, 3),
date("D", mktime(0, 0, 0, 11, 16, 1991)) => substr($wdays[6], 0, 3)
);
$replace_months = array(
date("F", mktime(0, 0, 0, 1, 1, 2004)) => $months[1],
date("F", mktime(0, 0, 0, 2, 1, 2004)) => $months[2],
date("F", mktime(0, 0, 0, 3, 1, 2004)) => $months[3],
date("F", mktime(0, 0, 0, 4, 1, 2004)) => $months[4],
date("F", mktime(0, 0, 0, 5, 1, 2004)) => $months[5],
date("F", mktime(0, 0, 0, 6, 1, 2004)) => $months[6],
date("F", mktime(0, 0, 0, 7, 1, 2004)) => $months[7],
date("F", mktime(0, 0, 0, 8, 1, 2004)) => $months[8],
date("F", mktime(0, 0, 0, 9, 1, 2004)) => $months[9],
date("F", mktime(0, 0, 0, 10, 1, 2004)) => $months[10],
date("F", mktime(0, 0, 0, 11, 1, 2004)) => $months[11],
date("F", mktime(0, 0, 0, 12, 1, 2004)) => $months[12]
);
$replace_short_months = array(
date("M", mktime(0, 0, 0, 1, 1, 2004)) => substr($months[1], 0, 3),
date("M", mktime(0, 0, 0, 2, 1, 2004)) => substr($months[2], 0, 3),
date("M", mktime(0, 0, 0, 3, 1, 2004)) => substr($months[3], 0, 3),
date("M", mktime(0, 0, 0, 4, 1, 2004)) => substr($months[4], 0, 3),
date("M", mktime(0, 0, 0, 5, 1, 2004)) => substr($months[5], 0, 3),
date("M", mktime(0, 0, 0, 6, 1, 2004)) => substr($months[6], 0, 3),
date("M", mktime(0, 0, 0, 7, 1, 2004)) => substr($months[7], 0, 3),
date("M", mktime(0, 0, 0, 8, 1, 2004)) => substr($months[8], 0, 3),
date("M", mktime(0, 0, 0, 9, 1, 2004)) => substr($months[9], 0, 3),
date("M", mktime(0, 0, 0, 10, 1, 2004)) => substr($months[10], 0, 3),
date("M", mktime(0, 0, 0, 11, 1, 2004)) => substr($months[11], 0, 3),
date("M", mktime(0, 0, 0, 12, 1, 2004)) => substr($months[12], 0, 3)
);
$return = date($format, $timestamp);
$return = strtr($return, $replace_wdays);
$return = strtr($return, $replace_short_wdays);
$return = strtr($return, $replace_months);
$return = strtr($return, $replace_short_months);
return $return;
}
?>