'How convert Hijri date to gregorian in PHP?

I got the code from this

I have this date 1401/01/16(Hijri Islamic) want to convert it to 24-11-1980 normal date.

Code:

function HijriToJD($m, $d, $y)
{
    return (int)((11 * $y + 3) / 30) + 354 * $y +
        30 * $m - (int)(($m - 1) / 2) + $d + 1948440 - 385;
}

$r = HijriToJD(1, 16, 1401);
    
date("Y-m-d", $r);

// output is: "1970-01-29" and it should be "1980-11-24"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source