1. Go to this page and download the library: Download talal424/calendars library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
talal424 / calendars example snippets
use Talal424\Calendars\Calendars;
// get UmmAlQura calendar
$UmmAlQura = Calendars::calendar('UmmAlQura'); //object Talal424\Calendars\UmmAlQuraCalendar
// get Gregorian calendar
$Gregorian = Calendars::calendar('Gregorian'); // returns object Talal424\Calendars\GregorianCalendar
// get a new date
// $year, $month, $day
$date = $UmmAlQura->newDate(1406,4,9); // returns object Talal424\Calendars\CDate
// $format, CDate $date, $settings
echo $UmmAlQura->formatDate('yyyy/mm/dd E',$date,['localNumbers'=>false]); // returns string
// 1406/04/09 AH
// or
// $format, $settings
echo $date->formatDate('yyyy/mm/dd'); // returns string
// ١٤٠٦/٠٤/٠٩
// convert UmmAlQura date to Julian date
$jd = $date->toJD(); // returns string
$date = $Gregorian->fromJD($jd); // returns object Talal424\Calendars\CDate
// $format, $settings
echo $date->formatDate('yyyy/mm/dd'); // returns string
// 1985/12/21
// you can also do this
$date = $Gregorian->newDate(); // returns today's date object Talal424\Calendars\CDate
// this would use the default format of the calendar (Gregorian) 'mm/dd/yyyy'
echo $date; // returns string
// 01/28/2017
$defaultLanguage = 'english'; // this will be used for all calendars later on unless language code is set when calendar is called.
$regionalOptions = [
//Language Code
'Arabic' => [
'invalidCalendar' => 'لم يتم العثور على التقويم: {0}',
],
'English' => [
'invalidCalendar' => 'Calendar {0} not found',
]
];
Calendars::setLanguage('Arabic'); // this will set Arabic as the default language
// get UmmAlQura calendar
$UmmAlQura = Calendars::calendar('UmmAlQura'); // this will load the calendar with the default language and settings.
$UmmAlQura = Calendars::calendar('UmmAlQura','Arabic'); // this will load the calendar with the Arabic language and settings.