0

I just want to convert the date which is in this format dd-mm-yyyy(03-11-1991) into arabic no like this(۱۹۹۱/۱۱/۰۳) in php.

Answer I Made This Logic And It Works Perfect

   $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 */
Fahid Mahmood
  • 43
  • 1
  • 7
  • possible duplicate of [Convert English numbers to Arabic numerals](http://stackoverflow.com/questions/3386835/convert-english-numbers-to-arabic-numerals) – JJJ Jul 25 '12 at 09:24
  • Good but I would say that's not a proper way of doing it. Anyway Alhamdulillah! – M. Ahmad Zafar Jul 25 '12 at 09:57
  • JAZAKALLAH.Yes Brother You Were Right I Changed The Logic Again Because on previous one because of doing reverse string.. "03-11-2001" ۱۰۰۲/۱۱/۳۰//wrong but Know This Logic Is Working Perfect – Fahid Mahmood Jul 25 '12 at 10:15

2 Answers2

1

You can use the PHP Localization approach:

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

In case you didn't see Arabic letters rather Latin, this could be because the locale is not installed on your system. You can check the installed locales by running the command: locale -a

Please refer to the documentation for more options:
http://php.net/manual/en/function.strftime.php
http://php.net/manual/en/function.setlocale.php

M. Ahmad Zafar
  • 4,881
  • 4
  • 32
  • 44
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);

you can try str_replace function

arun
  • 3,667
  • 3
  • 29
  • 54