Best way to store Hijri dates in mysql?
I am developing a web application using CakePHP and mysql and all the dates in the system use the Islamic/Hijri calendar(http://en.wikipedia.org/wiki/Islamic_calendar) . I was wondering what is the best 开发者_运维问答way to store Hijri dates in mysql?
Note: I already use Keith Wood's jQuery DatePicker(http://keith-wood.name/datepick.html).
Actually, you don't have to use any external library . Use the Keith Wood Calendar plugin to convert the Hijri date to timestamp or to Gregorian . Then save it in a normal datetime field in mysql.
it is possible to translate between Hijri and Gregorian on the fly (see http://yse-uk.com/?page_id=13) so you could simply store your dates as Gregorian and convert them before displaying.
Only 3 years past, but... You can use a trick with Excel - if you create a custom format to a date column (make sure you have the Arabic language available).
Then you can create a looup table in your MySQL db. The format :
B2dd/mm/yyyy
Will format as Hijri dates, regardless of Regional settings and based on Micorsoft's Kuwait Algorithm. This might not convene with all Hijri calendars out there, but it simple and neat.
The format:
B1dd/mm/yyyy
Will format in Gregorian, regardless of regional settings. I know that SQLServer has these conversion functions as well, but I'm less an expert on it.
精彩评论