0

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"

regosa
  • 63
  • 1
  • 9
  • I don't know why, but the name of that function suggests that it is converting to a Julian Date - a notation commonly used by astronomers, represented as a number of days from a fixed point. For use with `date()`, you want a Unix timestamp, which is a number of *seconds* from a completely different fixed point, so the function is entirely unsuitable, unless you combine it with another conversion from Julian Date to timestamp. – IMSoP Apr 30 '22 at 15:42
  • @IMSoP Thanks I found the solution here: https://gist.github.com/RabeeaAli/c758cc9b46500f153eed73dc27fc87e9 – regosa Apr 30 '22 at 15:49

0 Answers0