PHP Classes

PHP Hijri Date Calendar: Convert and manipulate Hijri dates

Recommend this page to a friend!
  Info   View files Example   View files View files (74)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-12-03 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 737 All time: 4,524 This week: 94Up
Version Licenses PHP version Categories
hijri-date 2.3.4GNU General Publi...5.3PHP 5, Time and Date
Description 

Author

This package is specific mainly for applications used in Saudi Arabia Saudi Arabia .

This package can convert and manipulate Hijri dates.

It can perform several types of operations with dates in the Hijri calendar. Currently it can:

- Convert an Hijri date to a DateTime object
- Format Hijri dates
- Initialize a calendar class object to a given Hijri date
- Load Hum Al-Qura and apply adjustments
- Convert a Julian or Gregorian date to an Hijri date and vice-versa
- Return the month names in Arabic
- Check if it is a leap year
- Validate a Hijri date
- Etc..

Picture of Saeed Hubaishan
Name: Saeed Hubaishan <contact>
Classes: 2 packages by
Country: Yemen Yemen

Example

<?php

/*
 * example for Hijri Date Lib
 * by Saeed Hubaishan
 */
require_once '../hijri.class.php';
date_default_timezone_set('Asia/Aden');

function
buildMonthCal($month, $year, $outmonth = FALSE)
{
   
$c = new hijri\Calendar();
   
$d = new hijri\datetime('now', null, 'ar', $c);
    list(
$cday, $cmonth, $cyear) = explode('-', $d->format('_j-_n-_Y'));
   
   
$d->setDateHijri($year, $month + 1, 0);
    list(
$gm2, $gy2) = explode('-', $d->format("M-Y"));
   
$d->setDateHijri($year, $month, 1);
    list(
$start_wd, $month_name, $gm1, $gy1) = explode('-', $d->format("w-_M-M-Y"));
   
$title = $month_name . " " . $year . "?? (" . $gm1 . (($gy2 != $gy1) ? " " . $gy1 : '') . (($gm2 != $gm1) ? "-" . $gm2 : '') . " " . $gy2 . "?)";
   
   
$wd = array(0 => 1, 2, 3, 4, 5, 6, 0);
   
$month_length = $c->days_in_month($month, $year);
   
$b_month = $month - 1;
   
$b_year = $year;
    if (
$b_month == 0) {
       
$b_month = 12;
       
$b_year--;
    }
   
$a_month = $month + 1;
   
$a_year = $year;
    if (
$a_month == 13) {
       
$a_month = 1;
       
$a_year++;
    }
    echo
'<div class="navigation"><a class="prev" href="monthCalendar.php?month=' . $b_month . '&year=' . $b_year . '">&lt;</a>' . '<div class="title" >' . $title . '<a class= "next" href="monthCalendar.php?month=' . $a_month . '&year=' . $a_year . '">&gt;</a>' . '</div>
</div>'
;
    if (
$wd[$start_wd] > 0) {
       
$d->modify("-" . $wd[$start_wd] . " day");
    }
    echo
'<table>
    <tr>
        <th class="weekday">?????</th>
        <th class="weekday">?????</th>
        <th class="weekday">???????</th>
        <th class="weekday">????????</th>
        <th class="weekday">????????</th>
        <th class="weekday">??????</th>
        <th class="weekday">??????</th>
    </tr>'
;
   
$dayw = 0;
    do {
        list(
$hd, $hm, $hy, $gd, $gm, $gy) = explode('-', $d->format("_j-_n-_Y-j-n-Y"));
        if (
$dayw == 0) {
            echo
"<tr>";
        }
       
$class = '';
        if (
$cday == $hd && $cmonth == $hm && $cyear == $hy) {
           
$class = "today";
        } elseif (
$hm == $month) {
           
$class = "current";
        }
        echo
"<td class='$class'><a href='javascript: void(0)'>$hd<br/>&nbsp;<span class='gre'>$gd</span></a></td>";
        if (
$dayw == 6) {
            echo
"</tr>";
           
$dayw = 0;
            if ((
$hm > $month) || ($hy > $year) || ($hm == $month && $hd == $month_length)) {
                break;
            }
        } else {
           
$dayw++;
        }
       
$d->modify("+1 day");
    } while (
TRUE);
    echo
'</td></tr></table>';
}
$d = new hijri\datetime();
list(
$year, $month) = explode(' ', $d->format('_Y _n'));
// echo is_integer($_REQUEST['month'])).$_REQUEST['year'];
if (isset($_REQUEST['month']) && isset($_REQUEST['year'])) {
   
$tmonth = (int) $_REQUEST['month'];
   
$tyear = (int) $_REQUEST['year'];
   
    if (
$tmonth > 0 && $tmonth < 13) {
       
$year = $tyear;
       
$month = $tmonth;
    }
}
?>
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="utf-8" />
<meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>??????? ?????? ??????</title>
<!-- add styles and scripts -->
<style>
/* calendar styles */
#calendar {
    -moz-user-select: none;
    border: 1px solid #EEEEEE;
    border-radius: 6px 6px 6px 6px;
    color: #333333;
    font-family: Arial, sans-serif;
    font-size: 1.1em;
    margin: 10px auto;
    padding: 0.4em;
    width: 90%;
    direction: rtl;
}

#calendar .navigation {
    background-color: #CC0000;
    border: 1px solid #E3A1A1;
    border-radius: 6px 6px 6px 6px;
    color: #FFFFFF;
    font-weight: bold;
    padding: 1px;
    position: relative;
}

#calendar .navigation .title {
    background: none repeat scroll 0 0 transparent;
    border-color: rgba(0, 0, 0, 0);
    color: inherit;
    line-height: 1.8em;
    margin: 0 2.3em;
    text-align: center;
}

#calendar .navigation .prev, #calendar .navigation .next {
    text-decoration: none;
    color: #FFFFFF;
    height: 24px;
    opacity: 0.9;
    position: absolute;
    top: 4px;
    width: 24px;
}

#calendar .navigation .prev {
    background-position: 0 0;
    right: 4px;
}

#calendar .navigation .next {
    background-position: -24px 0;
    left: 4px;
}

#calendar .navigation .prev:hover, #calendar .navigation .next:hover {
    opacity: 1;
}

#calendar table {
    border-collapse: collapse;
    font-size: 0.9em;
    table-layout: fixed;
    width: 100%;
}

#calendar table th {
    border: 0 none;
    font-weight: bold;
    padding: 0.7em 0.3em;
    text-align: center;
}

#calendar table td {
    border: 0 none;
    padding: 1px;
}

#calendar table td a {
    background-color: #EEEEEE;
    border: 1px solid #D8DCDF;
    color: #004276;
    display: block;
    font-weight: normal;
    opacity: 0.7;
    padding: 0.2em;
    text-align: right;
    text-decoration: none;
}

#calendar table td a:hover {
    background-color: #F6F6F6;
    border: 1px solid #CDD5DA;
    color: #111111;
}

#calendar table td.current a {
    font-weight: bold;
    opacity: 1;
}

#calendar table td.today a {
    background-color: #FBF8EE;
    border: 1px solid #FCD3A1;
    color: #444444;
    font-weight: bold;
    opacity: 1;
}

#calendar span.gre {
    text-align: left;
    direction: ltr;
    color: #0080CC;
    float: left;
}
</style>
</head>
<body>
    <div id="calendar">
<?php
buildMonthCal
($month, $year)?>
</div>
</body>
</html>


Details

HijriDateLib

php classes to view and manage Hijri Calendar.

the lib has two algorithms to calculte Hijri Date:

1-Hijri Tabular algorithm

2- Um Al-Qura algoritm

Lib Features

  1. Two algorithms to calculte Hijri Date: Hijri Tabular algorithm, Um Al-Qura algorithm.
  2. The lib allows you to adjust the Hijri Um Al-Qura algorithm and save the adjustment.
  3. The lib has a full feature class to manage the adjustments of Um Al-Qura Calendar.
  4. The Lib has a datetime class extends the real php datetime class, and allows you to return Hijri Calendar with the Gregorian Calendar in one format and one command.
  5. The Hijri datetime class have all real php class Gregorian Calendar Functions plus main functions for Hijri Calendar.
  6. The Lib returns the Hijri Calendar months in 20 international Languages.
  7. The Um Al-Qura algorithm works from 1318 A.H to 1500 A.H. and Tabular Algorithm work from year 5499 before Hijra to 1,500,000 A.H, If Um Al-Qura algorithm selected and the date out of range the uses Tabular Algorithm instead.
  8. The has full api documents.

Requirments

The HijriDatLib requires at php version 5.3 at least. It is compatible up to php 8.1 .


  Files folder image Files  
File Role Description
Files folder imagedocs (1 file, 1 directory)
Files folder imageexamples (4 files)
Plain text file hijri.class.php Class Class source
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  docs  
File Role Description
Files folder imageapi (2 files, 11 directories)
  Accessible without login HTML file README-AR.html Doc. Documentation

  Files folder image Files  /  docs  /  api  
File Role Description
Files folder imageclasses (6 files)
Files folder imagecss (7 files, 1 directory)
Files folder imagefiles (3 files)
Files folder imagefont (1 file)
Files folder imagegraphs (2 files)
Files folder imageimages (12 files, 1 directory)
Files folder imageindices (1 file)
Files folder imagejs (12 files, 1 directory)
Files folder imagenamespaces (2 files)
Files folder imagepackages (2 files)
Files folder imagereports (3 files)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login HTML file index.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  classes  
File Role Description
  Accessible without login HTML file hijri-Calendar.html Doc. Documentation
  Accessible without login HTML file hijri-CalendarAdjustment.html Doc. Documentation
  Accessible without login HTML file hijri-datetime.html Doc. Documentation
  Accessible without login HTML file hijri.Calendar.html Doc. Documentation
  Accessible without login HTML file hijri.CalendarAdjustment.html Doc. Documentation
  Accessible without login HTML file hijri.datetime.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  css  
File Role Description
Files folder imagephpdocumentor-clean-icons (3 files, 1 directory)
  Accessible without login Plain text file base.css Data Auxiliary data
  Accessible without login Plain text file bootstrap-combined.no-icons.min.css Data Auxiliary data
  Accessible without login Plain text file font-awesome.min.css Data Auxiliary data
  Accessible without login Plain text file jquery.iviewer.css Data Auxiliary data
  Accessible without login Plain text file normalize.css Data Auxiliary data
  Accessible without login Plain text file prism.css Data Auxiliary data
  Accessible without login Plain text file template.css Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  css  /  phpdocumentor-clean-icons  
File Role Description
Files folder imagefonts (2 files)
  Accessible without login Plain text file lte-ie7.js Data Auxiliary data
  Accessible without login Plain text file Read Me.txt Doc. Documentation
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  css  /  phpdocumentor-clean-icons  /  fonts  
File Role Description
  Accessible without login Plain text file phpdocumentor-clean-icons.dev.svg Data Auxiliary data
  Accessible without login Plain text file phpdocumentor-clean-icons.svg Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  files  
File Role Description
  Accessible without login HTML file hijri-class.html Doc. Documentation
  Accessible without login HTML file hijri.class.html Doc. Documentation
  Accessible without login Plain text file hijri.class.php.txt Doc. Documentation

  Files folder image Files  /  docs  /  api  /  font  
File Role Description
  Accessible without login Plain text file fontawesome-webfont.svg Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  graphs  
File Role Description
  Accessible without login HTML file class.html Doc. Documentation
  Accessible without login HTML file classes.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  images  
File Role Description
Files folder imageiviewer (8 files)
  Accessible without login Image file apple-touch-icon-114x114.png Icon Icon image
  Accessible without login Image file apple-touch-icon-72x72.png Icon Icon image
  Accessible without login Image file apple-touch-icon.png Icon Icon image
  Accessible without login Plain text file custom-icons.svg Data Auxiliary data
  Accessible without login Image file favicon.ico Data Auxiliary data
  Accessible without login Image file hierarchy-item.png Icon Icon image
  Accessible without login Image file icon-class-13x13.png Icon Icon image
  Accessible without login Plain text file icon-class.svg Data Auxiliary data
  Accessible without login Image file icon-interface-13x13.png Icon Icon image
  Accessible without login Plain text file icon-interface.svg Data Auxiliary data
  Accessible without login Image file icon-trait-13x13.png Icon Icon image
  Accessible without login Plain text file icon-trait.svg Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  images  /  iviewer  
File Role Description
  Accessible without login Image file grab.cur Data Auxiliary data
  Accessible without login Image file hand.cur Data Auxiliary data
  Accessible without login Image file iviewer.rotate_left.png Icon Icon image
  Accessible without login Image file iviewer.rotate_right.png Icon Icon image
  Accessible without login Image file iviewer.zoom_fit.png Icon Icon image
  Accessible without login Image file iviewer.zoom_in.png Icon Icon image
  Accessible without login Image file iviewer.zoom_out.png Icon Icon image
  Accessible without login Image file iviewer.zoom_zero.png Icon Icon image

  Files folder image Files  /  docs  /  api  /  indices  
File Role Description
  Accessible without login HTML file files.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  js  
File Role Description
Files folder imageui (1 directory)
  Accessible without login Plain text file bootstrap.min.js Data Auxiliary data
  Accessible without login Plain text file html5.js Data Auxiliary data
  Accessible without login Plain text file jquery-1.11.0.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.dotdotdot-1.5.9.js Data Auxiliary data
  Accessible without login Plain text file jquery.dotdotdot-1.5.9.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.iviewer.js Data Auxiliary data
  Accessible without login Plain text file jquery.iviewer.min.js Data Auxiliary data
  Accessible without login Plain text file jquery.mousewheel.js Data Auxiliary data
  Accessible without login Plain text file jquery.smooth-scroll.js Data Auxiliary data
  Accessible without login Plain text file prism.min.js Data Auxiliary data
  Accessible without login Plain text file search.js Data Auxiliary data
  Accessible without login Plain text file searchIndex.js Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  js  /  ui  
File Role Description
Files folder image1.10.4 (1 file)

  Files folder image Files  /  docs  /  api  /  js  /  ui  /  1.10.4  
File Role Description
  Accessible without login Plain text file jquery-ui.min.js Data Auxiliary data

  Files folder image Files  /  docs  /  api  /  namespaces  
File Role Description
  Accessible without login HTML file default.html Doc. Documentation
  Accessible without login HTML file hijri.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  packages  
File Role Description
  Accessible without login HTML file Application.html Doc. Documentation
  Accessible without login HTML file default.html Doc. Documentation

  Files folder image Files  /  docs  /  api  /  reports  
File Role Description
  Accessible without login HTML file deprecated.html Doc. Documentation
  Accessible without login HTML file errors.html Doc. Documentation
  Accessible without login HTML file markers.html Doc. Documentation

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file adjuster.php Example Example script
  Accessible without login Plain text file monthCalendar.php Example Example script
  Accessible without login Plain text file monthCalendar2.php Example Example script
  Accessible without login Plain text file monthCalendarGre.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:737
This week:0
All time:4,524
This week:94Up