|
Posted by Marc Nadeau on 10/28/98 11:29
talthen.z-serwera.o2@nospam.pl a écrit:
> "Jochem" <jdonkers@gmail.com>
>> The main issue is to translate things like "Tuesday, 11 October 2005"
>> into Danish (or any other language for that matter).
>
> Prepare tables like:
> Day array=(DanishNameOfDay1, DanishNameOfDay2...)
> Month array=(DanishNameofMonth1...)
> then get the date in format 01-28-08-2005 exploded into 4 variables:
> daynum,day, month,year.
> Then get the proper values from the arrays:
> DanishDate=$Day[$daynum]."-".$day."-".$Month[$month]...
>
> Regards,
> Talthen
I wrote this function for a french localisation project; should be easy to
translate. The whole librairy is copyrighted Marc Nadeau (me), 2005 and is
released unther the GNU Public Licence (GPL).
// $dateStandard means AAAA-MM-JJ format
function retournerDateTextuelle($dateStandard){
$annee = substr($dateStandard,0,4);
$mois = substr($dateStandard,5,2);
$jour = substr($dateStandard,8,2);
$moisNom['01'] = 'janvier';
$moisNom['02'] = 'février';
$moisNom['03'] = 'mars';
$moisNom['04'] = 'avril';
$moisNom['05'] = 'mai';
$moisNom['06'] = 'juin';
$moisNom['07'] = 'juillet';
$moisNom['08'] = 'août';
$moisNom['09'] = 'septembre';
$moisNom['10'] = 'octobre';
$moisNom['11'] = 'novembre';
$moisNom['12'] = 'décembre';
$moisTexte = $moisNom[$mois];
$dateFormatee = "$jour $moisTexte $annee";
// eliminate leading zeroes
if(substr($dateFormatee, 0, 1) == '0'){
$dateFormatee = substr($dateFormatee, 1);
}
return $dateFormatee;
}
Could be shortened or optimized but i like the clarity.
Hope that helps.
--
Cogito ergo sum... et tralala
Marc Nadeau, webmestre, La Pagerie, http://www.pagerie.com
[Back to original message]
|