<? include "date_fr.inc"; echo date_fr(time(),"Long"); >Le paramètre "Long" sert à spécifier la façon dont la date va être affichée, vous pouvez choisir un des 4 formats prédéfinis (si vous ne spécifiez pas explicitement un des trois premiers, c'est le quatrième qui sera choisi par défaut :
Voici un exemple de ce que ça donne
"Long"
"long"
"Short"
" ": Lundi 6 Juillet 1998
: lundi 6 juillet 1998
: Lun 6 Juil 1998
: lun 6 juil 1998
<?
function date_fr $timestamp,$mode
(
/* that function outputs dates in french. */;
/* works with PHP3. made 06.30.98 by mose@amberlab.net */;
/* $mode can be "Short", "long", "Long", or anything (default) */;
/* Modifié le 04/07/1998 par Bea... pour PHP/Fi 2.0 */;
/* ----------------------------------------------------------- */;
$result = "";
$dval = date("D",$timestamp);
$nval = intval(date("d",$timestamp));
$mval = intval(date("m",$timestamp));
$Yval = date("Y",$timestamp);
/* Feel free to personalize arrays for your mothertongue :-) */;
/* --------------------------------------------------------- */;
$day["Mon"] = "lundi";
$day["Tue"] = "mardi";
$day["Wed"] = "mercredi";
$day["Thu"] = "jeudi";
$day["Fri"] = "vendredi";
$day["Sat"] = "samedi";
$day["Sun"] = "dimanche";
$sday["Mon"] = "lun";
$sday["Tue"] = "mar";
$sday["Wed"] = "mer";
$sday["Thu"] = "jeu";
$sday["Fri"] = "ven";
$sday["Sat"] = "sam";
$sday["Sun"] = "dim";
$month[1] = "janvier";
$month[2] = "février";
$month[3] = "mars";
$month[4] = "avril";
$month[5] = "mai";
$month[6] = "juin";
$month[7] = "juillet";
$month[8] = "août";
$month[9] = "septembre";
$month[10] = "octobre";
$month[11] = "novembre";
$month[12] = "décembre";
$smonth[1] = "jan";
$smonth[2] = "fév";
$smonth[3] = "mars";
$smonth[4] = "avr";
$smonth[5] = "mai";
$smonth[6] = "juin";
$smonth[7] = "juil";
$smonth[8] = "août";
$smonth[9] = "sept";
$smonth[10] = "oct";
$smonth[11] = "nov";
$smonth[12] = "déc";
/* outputs the date with caps or not, long or short */;
/* ------------------------------------------------ */;
switch ($mode) {
case "Long";
$result = ucfirst($day[$dval])+
" " + $nval+" " + ucfirst($month[$mval])+" "+$Yval;
break; /* Mardi 30 Juin 1998 */;
case "long";
$result = "$day[$dval] $nval $month[$mval] $Yval";
break; /* mardi 30 juin 1998 */;
case "Short";
$result = ucfirst($sday[$dval]) +
" " + $nval+" " + ucfirst($smonth[$mval])+" "+$Yval;
break; /* Mar 30 Juin 1998 */;
default;
$result = "$sday[$dval] $nval $smonth[$mval] $Yval";
/* mar 30 juin 1998 */;
}
return($result);
);
/* to print the current date */;
/* ---------------------------- */;
/* echo date_fr(time(),"Long"); */;
>
Page consultée
fois.