Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hijri (Arabic) calendar date picker using PHP or Javascript [duplicate]

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.

like image 927
honki Avatar asked Nov 27 '12 06:11

honki


2 Answers

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

like image 52
khaled.alshamaa Avatar answered Sep 30 '22 02:09

khaled.alshamaa


The Arabic PHP Project may help you with PHP.

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

like image 37
SaidbakR Avatar answered Sep 30 '22 04:09

SaidbakR