将数字日期(03-11-1991)转换为阿拉伯数字(۱


Convert numeral date(03-11-1991) into arabic no(۱۹۹۱/۱۱/۰۳) php

我只想在php中将这种格式的日期dd-mm-yyyy(1991年3月11日)转换为阿拉伯语,而不是像这样(۱。

答案我做了这个逻辑,它完美地工作

   $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 */

您可以使用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

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函数