0

我只想在 php.ini 中将这种格式 dd-mm-yyyy(03-11-1991) 的日期转换成这样的阿拉伯语(1991/111/03)。

答案 我做了这个逻辑,它完美无缺

   $dateofbirth_numerial="03-05-2001";
                             $numerial_no = array("0","1","2","3","4","5","6","7","8","9","-");
                             $arabic_no = array("۰","۱","۲","۳","۴","۵","۶","۷","۸","۹","/");
                             $dateofbirth_arabic = str_replace($numerial_no , $arabic_no , $dateofbirth_numerial);
                             $result = explode('/',$dateofbirth_arabic);
                             echo $result[2]."/".$result[1]."/".$result[0]; /* yyyy/mm/dd */
4

2 回答 2

1

您可以使用 PHP 本地化方法:

    setlocale(LC_TIME, 'ar');
    $arabic = strftime('%A %e %B %Y', time());
    echo $arabic;

如果您没有看到阿拉伯字母而是拉丁字母,这可能是因为您的系统上没有安装语言环境。您可以通过运行以下命令检查已安装的语言环境:locale -a

有关更多选项,请参阅文档:http:
//php.net/manual/en/function.strftime.php
http://php.net/manual/en/function.setlocale.php

于 2012-07-25T09:35:50.253 回答
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-11-06T08:56:57.597 回答