1

我有变量包含日期,我想用阿拉伯语打印这个日期。日期(阿拉伯语月份)我该怎么做?

4

5 回答 5

12

尝试这个:

$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.

于 2012-12-11T10:56:34.240 回答
1

添加这个:

setlocale (LC_ALL, "ar_AE");

然后打印你的日期。

于 2012-12-11T10:36:00.547 回答
1

您可以这样安装和使用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.
于 2012-12-11T10:55:04.603 回答
0

为什么不检查英文月份,然后打印对应的阿拉伯文?

于 2012-12-11T10:33:12.373 回答
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功能

于 2012-12-11T10:51:38.623 回答