Issue
Here is the dbtest.table_t
id name year
1 abc 2014
did trigger so the column year will take default current year base on system time now.
TRIGGER `db_test`.`ins_year`
BEFORE INSERT ON `dbtest`.`table_t`
FOR EACH ROW
set new.year = year(now())$$
insert into table_t (`id`,`name`) value (`2`,`def`);
the result will be
id name year
2 def 2014 // as 2014 is current year of the system it will take default.
but i want this in hijri shamsi(arabic celender) as for exampe now is the year 1393
how i can set like this.
id name year
1 abc 1392
2 def 1392
3 efg 1392
As I have enter the up records in 1392 but now is 1393 according to the system year.
When I insert:
insert into table_t (`id`,`name`) value (`4`,`hij`)
Result should set the
id name year
4 hij 1393
How to make the mysql database to select year based on Hijri shamsi?
If in PHP I do echo $date = date("Y");
it will show me now year(2014).
How I can echo that show me Hijri shamsi (1393) in PHP?
Also how I can translate my up trigger to have result in Hijri shamsi?
Regards
Solution
Check the PHP manuel for calendar functions, in the user contributed notes section there is a class for converting the Julian To Hijri, FYI there is no official support for Hijri calendar in the PHP API or MySQL ! link: http://www.php.net/manual/en/ref.calendar.php#54234
Answered By – e-nouri
Answer Checked By – Marie Seifert (BugsFixing Admin)