note 89101 deleted from function.date by danbrown
| From: | danbrown@php.net | Date: | Sun, 22 Feb 2009 00:37:26 +0000 |
| Subject: | note 89101 deleted from function.date by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150944@lists.php.net to get a copy of this message | ||
Note Submitter: bastien at selfbuild dot fr
Reason: non-english
----
La fonction date en français avec les même paramètres et les jours et mois en français :
<?php
function datefr($format,$timestamp=false)
{
global $datefr_cache;
$datefr_cache=null;
if(isset($datefr_cache[$timestamp]))
{
return $datefr_cache[$timestamp];
}
else
{
global $datefr_jours,$datefr_mois,$datefr_mois3l;
if(empty($timestamp)) $timestamp=time();
$offset=0;
for($i=0;$i<strlen($format);$i++)
{
if(false===strpos('DlSFM',$format[$i]))
continue;
$cas=0;
while($format[$i-1-$cas]=='\\') $cas++;
if($cas%2==1)
continue;
if(!isset($datefr_cache[$timestamp][$format[$i]]))
{
switch($format[$i])
{
case 'l': $car=date_escape($datefr_jours[date('w',$timestamp)]); break;
case 'D':
$car=date_escape(substr($datefr_jours[date('w',$timestamp)],0,3)); break;
case 'F': $car=date_escape($datefr_mois[date('n',$timestamp)]); break;
case 'M': $car=date_escape($datefr_mois3l[date('n',$timestamp)]); break;
case 'S': if(date('j')==1) $car='er'; else $car='';
break;
default: $car='';
}
$datefr_cache[$timestamp][$format[$i]]=$car;
}
else
{
$car=$datefr_cache[$timestamp][$format[$i]];
}
$return.=substr($format,$offset,$i-$offset).$car;
$offset=$i+1;
}
$return.=substr($format,$offset);
$return=date($return,$timestamp);
$datefr_cache[$timestamp]=$return;
return $return;
}
}
?>