PHP Classes

PHP Jalali to Gregorian Date Converter and Comparison: Convert dates between Gregorian and Jalali

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 87 All time: 9,998 This week: 50Up
Version License PHP version Categories
dateconveter 1.0.0MIT/X Consortium ...5PHP 5, Time and Date
Description 

Author

This class can convert dates between the Gregorian and Jalali calendars.

It can take a given date and convert it between the Gregorian and the Jalali calendar and vice versa.

The class can also compare date in the Jalali calendar and compare it to another in the Gregorian calendar to determine if they correspond to the same date.

Innovation Award
PHP Programming Innovation award nominee
October 2018
Number 11
This package can process text to apply rules to display arabic text.

It can take a given text string and can apply several types of filters that can process arabic text so it can be rendered in a more convinient way.

Manuel Lemos
Picture of Ali Bayat
Name: Ali Bayat <contact>
Classes: 1 package by
Country: Iran Iran
Age: ???
All time rank: 443594 in Iran Iran
Week rank: 180 Up2 in Iran Iran Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php


// two different dates to test functionality
$gd = [2022,7,19];
$jd = [1410,10,20];

// instansiating the class and using methods
$dConverter = new dateConverter();
$j_date = $dConverter->toJalali($gd[0], $gd[1], $gd[2], true);
$g_date = $dConverter->toGregorian($jd[0], $jd[1], $jd[2], true);
$comparedDates = $dConverter->compareDate($j_date, $g_date);

// print the results
echo "Converting Gregorian <b>( $gd[0]/$gd[1]/$gd[2] )</b> to Jalali: <b>( $j_date )</b><br><br>";
echo
"Converting Jalali <b>( $jd[0]/$jd[1]/$jd[2] )</b> to Gregorian: <b>( $g_date )</b><br><br>";

// comparing two dates
if ($dConverter->compareDate($j_date, $g_date)) {
    echo
"Both Dates Match...<b> $j_date == $g_date </b>";
}
else {
    echo
"Comparing Dates didn't Match... <b> $j_date != $g_date </b>";
}

?>


  Files folder image Files (2)  
File Role Description
Plain text file dateConverter.php Class Main Class File
Plain text file index.php Example how to use the script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:87
This week:0
All time:9,998
This week:50Up