Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to convert Gregorian(English) into Hirji date(Arabic)

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 314
    Comment on it

    Hello Reader's, If you are developing an Arabic website where you want to convert English date into Arabic Date then this blog is very helpful to you.

    In Hijri date the number symbols are convert into islamic language. 

    So first we need a function which will convert the one by one digits of date into Arabic. And its code will be go  like this:-

     public function changeDate($date)
            {         
    
                $months = array(
                    "1" => "",
                    "2" => "",
                    "3" => "",
                    "4" => "",
                    "5" => "",
                    "6" => "",
                    "7" => "",
                    "8" => "",
                    "9" => "",
                    "10" => "",
                    "11" => "",
                    "12" => ""
                );
    
                $date_exp = explode('/', $date);
                $ar_dar = $date_exp[2]; //used as year now
                $en_month = $date_exp[1];  //used as month as same
                $ar_year = $date_exp[0]; //used as month now
    
           
                $standard = array("0","1","2","3","4","5","6","7","8","9");
                $eastern_arabic_symbols = array("","","","","","","","","","");
                $current_date = $ar_year.'/'. $ar_month.'/'.$ar_dar;
                $arabic_date = str_replace($standard , $eastern_arabic_symbols , $current_date);
                return $arabic_date = str_replace(' ', '', $arabic_date);
            }

    The above function is taking the input param as string $date and will make it digits replacement into arabic and return it.

    To use this function we will use it as below:-

    $date_arabic = (string)$this->changeDate( get_the_time('Y/m/d') );

    Output of this function is as below:-

      // 

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: