我写了一门课来翻译不同语言/格式的日期。对不起,我重新发布了这个问题,因为上次我发布了它,我失去了我的互联网连接,人们离开了这个话题......
这是完整的课程...
class GetDateTime {
private $_text_en_US = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "January", "February", "March", "April", "May","June", "July", "August", "September","October", "November", "December");
private $_text_fr_FR = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche", "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
public function getDateTime($format='d/m/Y', $timestamp, $locale='fr_FR') {
switch ($format) {
case 'd/m/Y':
case 'm/d/Y':
return date($format, $timestamp);
break;
case 'l d F Y':
return str_replace($_text_en_US, ${'_text_'.$locale}, date($format, $timestamp));
break;
}
}
}
...以及我如何称呼它:
include_once (BASE_DIR.'/lib/dateTime.class.php');
$dateTime = new GetDateTime();
事实是当我打电话时它根本没有翻译:
echo $dateTime->getDateTime('l d F Y', time());