Convert Christian solar calendar into Muslim Lunar calander using PHP [closed]
I am using PHP and want to mark religious holidays on Christian calendar. How could I convert Christian solar calendar into Muslim Lunar calendar?
Thanks.
Note that for most Muslims, the Hijri/Hegira calendar is based on observation, not calculation, so no algorithm can be 100% correct. With precise astronomical calculations, a specific reference location, and a weather forecast, you can get close, and some communities have discussed adopting such algorithmic approaches. But canonically, in order for a month to be 29 days long instead of 30, an official authority has to physically see the crescent moon in the sky at sunset after the 29th day. This is not a standard that lends itself to easy automation.
For general edification around this topic, I recommend the book Calendrical Calculations, which is an entertaining discussion of the mathematics of calendar conversion. It includes Lisp and Java code for converting among a large number of calendars, including two different takes on the Hijri - one a simple arithmetical approximation that has been used for centuries, the other a careful attempt at lunar crescent observation prediction. The authors have a website at http://calendarists.com.
PHP doesn't seem to have inbuilt support for this, but there are several libraries available. Take a look at this for example:
http://www.phpclasses.org/package/3850-PHP-Convert-between-Hijri-Gregorian-dates-and-format-.html
精彩评论