I want to get synchronized Hijri and Gregorian and store both in database in php. How can it be done?
Use HijriDateLib to convert Hijri dates to Gregorian, store dates is database as unix timestamp (data type bigint).
First you must download and require the Hijri class
<?php
require_once('hirji.class.php');
To return current date with both Hijri and Gregorian use:
echo (new hijri\datetime())->format('D _j _M _Yهـ (j-m-Yم)');
to store Hijri date in database:
SQL="INSERT IN table1 (timestamp_colum) VALUES " . (hijri\datetime::createFromHijri(1441,9,17))->format('U');
to view stored date with both Hijri and Gregorian:
echo (new hijri\datetime($row->timestamp_column))->format('D _j _M _Yهـ (j-m-Yم)');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With