我有这条线
<?php
echo date('H:i, d F Y',strtotime($i->date_start));
?>
哪个输出:
20:24, Saturday, 07 December 2013
如何将其翻译成我的当地语言?
答案 0 :(得分:1)
您可以将str_ireplace与搜索数组和替换数组一起使用。
$monthsDaysEn = array('January','February','March','Saturday','etc'); //populate with all months/days you want translated
$monthsDaysEs = array('enero','febero','marzo','Sabado','etc'); //populate in same order with their counterparts
$datestr = "20:24, Saturday, 07 March 2013";
$translated = str_ireplace($monthsEn,$monthsEs,$datestr);
echo $translated;