Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Get Hijri Equivalent Date of Gregorian Date?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 657
    Comment on it

    Hello Reader's!

    In this blog, we will see how to get conversion of Gregorian date into Hirji (Islamic date).

    Before you start the getting the equivalent you must be knowing that Hijri Calendar is about 400 year lags behind our current calendar (Gregorian).

     Let's start working on this:-

    First, create a function and name it Greg2Hijri() 
    This function will take three params as day, month, year. Now the conversion will take process inside it.

    function Greg2Hijri($day, $month, $year) {
        $day = (int) $day;
        $month = (int) $month;
        $year = (int) $year;
    
        if (($year > 1582) or ( ($year == 1582) and ( $month > 10)) or ( ($year == 1582) and ( $month == 10) and ( $day > 14))) {
            $jd = intPart((1461 * ($year + 4800 + intPart(($month - 14) / 12))) / 4) + intPart((367 * ($month - 2 - 12 * (intPart(($month - 14) / 12)))) / 12) -
                    intPart((3 * (intPart(($year + 4900 + intPart(($month - 14) / 12) ) / 100) ) ) / 4) + $day - 32075;
        } else {
            $jd = 367 * $year - intPart((7 * ($year + 5001 + intPart(($month - 9) / 7))) / 4) + intPart((275 * $month) / 9) + $day + 1729777;
        }
    
        $l = $jd - 1948440 + 10632;
        $n = intPart(($l - 1) / 10631);
        $l = $l - 10631 * $n + 354;
        $j = (intPart((10985 - $l) / 5316)) * (intPart((50 * $l) / 17719)) + (intPart($l / 5670)) * (intPart((43 * $l) / 15238));
        $l = $l - (intPart((30 - $j) / 15)) * (intPart((17719 * $j) / 50)) - (intPart($j / 16)) * (intPart((15238 * $j) / 43)) + 29;
        $month = intPart((24 * $l) / 709);
        $day = $l - intPart((709 * $month) / 24);
        $year = 30 * $n + $j - 30;
        $date = array();
        $date['year'] = $year;
        $date['month'] = $month;
        $date['day'] = $day;
        header('Content-Type: text/html; charset=utf-8');
        $standards = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
        $easterns_arabic_symbols = array("", "", "", "", "", "", "", "", "", "");
        $post_date = "{$year}/{$month}/{$day}";
        $arabic_date = str_replace($standards, $easterns_arabic_symbols, $post_date);
        return $arabic_date;
    }

    The output of this calendar will not be the English numbers, Instead, it will be an Arabic letters.

    Now we will access this function as follows:-

    $post_date_hirji = Greg2Hijri($current_date_explode[2], $current_date_explode[1], $current_date_explode[0]);

    The output of this function will be as follows:-

    //     |   //

 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: