The Hijri Date script below is available free of charge to all non-profit* organisations adopting the UK Ulama moon sighting criteria for the UK/Morocco region.
It is very easy to implement on any website, app, software or anything that can read remote data.
The API is here:
https://scripts.moonsighting.org.uk/hijri.php
You can use the js extension for Javascript or PHP (it doesn't really matter, .js just makes it seem like it's pure Javascript)
Hence, https://scripts.moonsighting.org.uk/hijri.js will also work.
Adding to your website home-page:
<script type="text/Javascript" src="https://scripts.moonsighting.org.uk/hijri.js"></script>
Using the data in different formats:
If you need to simply fetch data, you can have it returned in the following formats:
By default: It'll be Javascript
HTML: https://scripts.moonsighting.org.uk/hijri.js?return=html
JSON: https://scripts.moonsighting.org.uk/hijri.js?return=json
CSV: https://scripts.moonsighting.org.uk/hijri.js?return=csv
CSS: https://scripts.moonsighting.org.uk/hijri.js?return=css
Using the CSS return method:
The CSS returns a full HTML pre formatted with css class names. You only need to create the css to format it however you want.
<style type="text/css>
.islamic_date_container{
display: block;
border: solid 1px #aaa;
background-color: #f6f6f6;
padding: 10px;
text-align: center;
font-family: Verdana, Geneva, sans-serif;
width: 150px;
}
.islamic_day{ font-size: 11px; line-height: 18px; }
.islamic_date{ font-weight: bold; color: #777; font-size: 40px; display: block; }
.islamic_month{ display: block; padding: 5px; }
.islamic_year{ font-weight: bold; }
.greg_date_container{ display: none; } /* We'll just ignore the gregorian date */
</style>
<script type="text/Javascript" src="https://scripts.moonsighting.org.uk/hijri.js?return=css"></script>
Result:
Using JSON to format in PHP:
$json = file_get_contents("https://scripts.moonsighting.org.uk/hijri.php?return=json");
if($json){
$hijri_data = json_decode($json, true);
$islamic_day = $hijri_data['islamic'][0];
$islamic_date = $hijri_data['islamic'][1];
$islamic_month = $hijri_data['islamic'][2];
$islamic_year = $hijri_data['islamic'][3];
//do as you wish here with the date (example on next line)
echo "<strong>$islamic_day</strong> <span style=\"font-size: 16px;\">$islamic_date</span> <em>$islamic_month</em> $islamic_year";
}
Checking specific date (if available):
Simply add date=2012-10-01 to query string where 2012-10-01 (yyyy-mm-dd) would be the date you actually want. So to see what Islamic date it'll be on 10th July 2013, you can use:
https://scripts.moonsighting.org.uk/hijri.js?return=html&date=2013-07-10
(The links are returned as HTML so you can view it in your browser, if you click it. Otherwise, to use as Javascript on your webpages, ensure you remove return=html from the URL).
Note that the Hijri date changes at midnight of UK local times, even though it is effective from the sunset of the previous day.
Reference Table:
| Query | Description | Acceptable Values | Example |
|---|---|---|---|
| return | Specifies the format of the returned data | Default: [blank] html json csv css |
hijri.js?return=json |
CSS Returns the following classes: .islamic_date_container |
|||
| date | Returns the Islamic date of any given date. Format of date must be yyyy-mm-dd | Gregorian date yyyy-mm-dd |
hijri.js?date=2012-03-18 |
| obsdate | Returns the Gregorian date of 29th and the next Islamic date (30th or 1st) |   | hijri.js?obsdate=1 |
*For commercial organisations using the script/API, a one-off
donation of £100
to ICOUK is requested to support our on-going development costs.
If you have any comments or suggestions regarding the above hijri script, please send it to Eng Qamar Uddin (www.moonsighting.org.uk). Jazak-Allah.
| Copyright © 2012 - 2018 Moon Sighting UK / ICOUK All rights
reserved Calendar script donated by TGL Services | Hosting Solutions |
Legal Notices: Terms Of Use | Privacy Policy |