Code Monkey home page Code Monkey logo

hijridatetime's Introduction

Hijri Date Time

Hijri Date Time library is a convenient and complete solution for users who want to use Hijri date in their projects and convert Gregorian calendar to Hijri (Islamic) calendar. This library is 100% compatible with "Umm al-Qura" formal calendar in Saudi Arabia and the Muslim world.

It support Arabic, English, France, and Indonesia languages.

The original source here

Extension for Yii2 Framework available here

Installation

The preferred way to install this library is through composer.

Just run

composer require biladina/hijridatetime

Usage

Once the library is installed, simply use it in your code by :

<?php

use biladina\hijridatetime\HijriDateTime;

// Choose Your Format Like 'l ، j F ، Y'
// Y => Hijri Year [1442]
// F => Hijri Month Arabic Name [رمضان]
// j => Hijri Day Number [27]
// l => Arabic Day Name [الجمعة]
// m => Hijri Month Number [09]
// a => 'ص'
// A => 'صباحًا'
// H => Hour
// i => Minutes
// s => Seconds

// set language is available, use 'ar' for Arabic, 'en' for English, 'fr' for France, and 'id' for Indonesia (which is the default language).

$hijri = new HijriDateTime();

$hijri->date("H:i A l, d F Y", time()) // formatting is like date function
// will return in Indonesia language if not set languange
// will return 16:16 PM Jum'at, 01 Ramadhan 1441
//---------------- Or ---------------------
$hijri->date("H:i A l, d F Y", time(), "fr")
// will return in France language
// will return 16:16 PM vendredi, 01 Ramadan 1441

$hijri->GeToHijr(20, 02, 1976)
// will return Array Hijri date[int month, int day, int year, int ln, int ml]

$hijri->strToHijri("24 April 2020")
// will return a Date in Hijri d-m-Y if not formated
//-------- Or -----------
$hijri->strToHijri("24 April 2020 15:00:00", "l, d F Y H:i A")
// will return in Indonesia language if not set languange
// will return a Date in Hijri as formated like Jum'at, 01 Ramadhan 1441 15:00 PM
//-------- Or -----------
$hijri->strToHijri("24 April 2020 15:00:00", "l, d F Y H:i A", "fr")
// will return in France language
// will return a Date in Hijri as formated like vendredi, 01 Ramadan 1441 15:00 PM

If you want to add more language :

  • open 'language' directory
  • copy one of directory in it (I prefer 'en' directory) and rename with initial of your country, like 'ms' for Malaysia, 'de' for Deutch (Germany)
  • open 'hijri.php' file in the renamed directory
  • translate to your languange
  • create PR, I will combine to main project

hijridatetime's People

Contributors

biladina avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

hijridatetime's Issues

output format different from input format

I am trying to convert a Gregorian date to Hijri Date, but single month digits are not getting prefixed with 0, How could we fix it

Here is the code I tried, output is 30-7-1399

<?php

use biladina\hijridatetime\HijriDateTime;

$dob = date('d-m-Y', strtotime('1979-06-24 03:00:00'));
echo $dob;
echo "\n";
$hijri = new HijriDateTime();
$hijriDOB =  $hijri->strToHijri($dob, 'd-m-Y');
echo $hijriDOB;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.