我有变量包含日期,我想用阿拉伯语打印这个日期。日期(用阿拉伯语写的几个月)我怎么能这样做?
答案 0 :(得分:11)
试试这个:
$months = array(
"Jan" => "يناير",
"Feb" => "فبراير",
"Mar" => "مارس",
"Apr" => "أبريل",
"May" => "مايو",
"Jun" => "يونيو",
"Jul" => "يوليو",
"Aug" => "أغسطس",
"Sep" => "سبتمبر",
"Oct" => "أكتوبر",
"Nov" => "نوفمبر",
"Dec" => "ديسمبر"
);
$your_date = "2012-12-25"; // for example
$en_month = date("M", strtotime($your_date));
$ar_month = $months[$en_month];
echo $en_month . " = " . $ar_month;
这将输出:Dec = ديسمبر
,它取决于$your_date
。
答案 1 :(得分:1)
添加:
setlocale (LC_ALL, "ar_AE");
然后打印你的约会。
答案 2 :(得分:0)
为什么不用英语检查月份然后打印阿拉伯语等价物?
答案 3 :(得分:0)
header('Content-Type: text/html; charset=utf-8');
$standard = array("0","1","2","3","4","5","6","7","8","9");
$eastern_arabic_symbols = array("٠","١","٢","٣","٤","٥","٦","٧","٨","٩");
$current_date = date('d').'-'.date('m').'-'.date('Y');
$arabic_date = str_replace($standard , $eastern_arabic_symbols , $current_date);
您可以尝试str_replace
功能
答案 4 :(得分:0)
您可以像这样安装和使用IntlDateFormatter
:
$formatter = new IntlDateFormatter('ar_SA',IntlDateFormatter::FULL,IntlDateFormatter::FULL);
$date = new DateTime();//now;
echo $formater->formate($date);//will print you something in arabic with the order that is used localy instead of english order.