Skip to content

Instantly share code, notes, and snippets.

@MukhtaarAziz
Last active July 4, 2022 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MukhtaarAziz/df2288ad6cac77526e98b5300171b886 to your computer and use it in GitHub Desktop.
Save MukhtaarAziz/df2288ad6cac77526e98b5300171b886 to your computer and use it in GitHub Desktop.
PHP

PHP Snippets

How can I convert Hijri date to gregorian in PHP?

// usage: $date = HijriToJD(M,d,Y);
function HijriToJD($m, $d, $y){
   return (int)((11 * $y + 3) / 30) + 354 * $y +
     30 * $m - (int)(($m - 1) / 2) + $d + 1948440 - 385;
}
$date = HijriToJD(9, 13, 1436);
echo jdtogregorian($date);

How can I convert Hijri date to gregorian in PHP? (more accurate)

// usage: $date = HijriToJD(M,d,Y);
function HijriToJD($m, $d, $y){
  return floor((11 * $year + 3) / 30) + floor(354 * $year) + floor(30 * $month)
            - floor(($month - 1) / 2) + $day + 1948440 - 386;
}

$date = HijriToJD(9, 13, 1436);
echo jdtogregorian($date);

Covert Hijri date to gregorian in PHP

This method use the library ar-php

$Arabic = new \ArPHP\I18N\Arabic();
echo $Arabic->date('Y-m-d',$Arabic->mktime(0,0,0,1,1,1443),0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment