Hijri (Arabic) calendar date picker using PHP or Javascript

10,361

Solution 1

You have to use a library/class do that conversion job for you, one of the available options is what Ar-PHP library provides (it is free open source library published under LGPL license), please find below an example code:

date_default_timezone_set('UTC'); 
$time = time(); 

require('I18N/Arabic.php'); 
$obj = new I18N_Arabic('Date'); 

$fix = $obj->dateCorrection ($time); 

echo $obj->date('l dS F Y h:i:s A', $time, $fix); 

You can find a life example and check the output here

More information about how calculation itself done can be found here

Solution 2

The Arabic PHP Project may help you with PHP.

http://www.ar-php.org/features-php-arabic.html

Share:
10,361
Admin
Author by

Admin

Updated on July 26, 2022

Comments

  • Admin
    Admin almost 2 years

    I am working on a project that has a form which requires the user to input a date using the Hijri (Arabic) calendar. I am only familiar with Javascript datepickers for the Gregorian calendar.

    I searched a lot on the internet and the closest I got was JS code for the Persian calendar, which is in Arabic, but everything else is different. For example the names of the days, months etc. And the Persian calendar is based on the solar calendar.

    Anyway, please advise on what I can do.

    Thanks.