Search code examples
phphijri

How to convert hijric date into strtotime


Im doing a project in php, right now i had faced a problem with hijric date conversion I dont know how to convert hijric date into strtotime(); or how to convert hijric date into gregorian date (date is YYYY-MM-DD format)

$your_date = strtotime('1439-03-09');

This wont get the strtotime value of hijric date Please help me solve this issue

Thank you


Solution

  • You can use the available Hijri to gregorian converter class to get gregorian date first than use strtotime to get your required output

    include "Hijri_GregorianConvert.class.php";
    $DateConv=new Hijri_GregorianConvert;
    $format="YYYY/MM/DD";
    $hijriDate="1439-03-09";
    $gregorianDate = $DateConv->HijriToGregorian($hijriDate,$format);
    echo "Hijri to Gregorian Result: ".$gregorianDate."<br>";
    echo $your_date = strtotime($gregorianDate);
    

    this class also offer some additional features related to hijri date.