1. Go to this page and download the library: Download andegna/calender 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/ */
andegna / calender example snippets
// create a gregorian date using PHP's built-in DateTime class
$gregorian = new DateTime('next monday');
// just pass it to Andegna\DateTime constractor and you will get $ethiopian date
$ethipic = new Andegna\DateTime($gregorian);
$timestamp = time(); // or some other place ¯\_(ツ)_/¯
$ethipic = Andegna\DateTimeFactory::fromTimestamp($timestamp);
$sheger = new DateTimeZone('Africa/Addis_Ababa');
$ethiopic = Andegna\DateTimeFactory::fromTimestamp($timestamp, $sheger);
$gregorian = new DateTime('Thu, 11 May 2017 19:01:26 GMT');
$ethiopic = Andegna\DateTimeFactory::fromDateTime($gregorian);
// or just pass it through the constractor
$ethiopic = new Andegna\DateTime(new DateTime('next sunday'));
// passing the format followed by the date string you got
$gregorian1 = DateTime::createFromFormat('j-M-Y', '15-Feb-2009');
$gregorian2 = DateTime::createFromFormat('m-j-Y', '12-31-1999');
$gregorian3 = DateTime::createFromFormat('Y-m-d H:i:s', '2009-02-15 15:16:17');
$gregorian1 = new DateTime('next sunday');
$gregorian2 = new DateTime('yesterday');
$gregorian3 = new DateTime('1999-12-31');
$gregorian4 = new DateTime('2123-12-31 12:34:56');
$gregorian_bad = new DateTime('12-31-1999'); // this one probably fails
$gregorian = new DateTime('now');
$ethiopic = Andegna\DateTimeFactory::fromDateTime($gregorian);
// but we provided some shortcuts
$now1 = \Andegna\DateTimeFactory::now();
$now2 = new DateTime();
// if you wanna specify time zone
$sheger = new DateTimeZone('Africa/Addis_Ababa');
$now3 = \Andegna\DateTimeFactory::now($sheger);
// create some Ethiopian date how ever you want
$ethiopian_date = \Andegna\DateTimeFactory::now();
// you get a PHP DateTime object to play with
$gregorian = $now->toGregorian();
use Andegna\Converter\ToJdnConverter;
$converter = new ToJdnConverter(21,3,1986);
echo $jdn = $converter->getJdn(); // 2449322
$et = new Andegna\DateTime();
// ዓርብ, 04-ግን-2009 14:41:00 EAT
echo $et->format(DATE_COOKIE);
// create a Ethiopian Date `ToJdnConverter`
$converter = new Andegna\Converter\ToJdnConverter($et->getDay(), $et->getMonth(), $et->getYear());
// convert it to jdn
$jdn = $converter->getJdn();
// use the built-in php function to convert the jdn to the jewish calendar
$jewish_date1 = jdtojewish($jdn);
// 9/16/5777
echo $jewish_date1;
// it also support formating for the return string
$jewish_date2 = jdtojewish($jdn, true, CAL_JEWISH_ADD_ALAFIM_GERESH);
// convert the return string to utf-8
$jewish_date2 = iconv ('WINDOWS-1255', 'UTF-8', $jewish_date2);
// טז אייר ה'תשעז
echo $jewish_date2;
$day = 29;
$month = 4;
$year = 2017;
// get the jdn using the built in php function
$jdn = juliantojd($month, $day, $year);
// convert the jd to Ethiopian Date
$converter = new Andegna\Converter\FromJdnConverter($jdn);
// create a `Andegna\DateTime` from the converted date
$ethiopic = Andegna\DateTimeFactory::fromConverter($converter);
// ዓርብ, 04-ግን-2009 00:00:00 EAT
echo $ethiopic->format(DATE_COOKIE);
// Friday, 12-May-2017 00:00:00 EAT
echo $ethiopic->toGregorian()->format(DATE_COOKIE);
// let's start from today
$today = new Andegna\DateTime();
// Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object
$tomorrow = $today->add(new DateInterval('P1D'));
$after_some_days = $today->add(new DateInterval('P10DT4H'));
$after_6_hours = $today->add(new DateInterval('PT6H'));
// Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
$yesterday = $today->sub(new DateInterval('P1D'));
$before_some_days = $today->sub(new DateInterval('P10DT4H'));
$before_6_hours = $today->sub(new DateInterval('PT6H'));
// Alters the DateTime object
$tomorrow = $today->modify('+1 day');
$yesterday = $today->modify('-1 day');
$after_30_minutes = $today->modify('+30 minutes');
$after_30_minutes = $today->modify('next sunday');
$today = new Andegna\DateTime();
$tomorrow = (new Andegna\DateTime())->add(new DateInterval('P1DT2M3S'));
$diff = $today->diff($tomorrow); // returns a DateTimeInterval
var_dump($diff);
$now = new Andegna\DateTime();
// Let's play a game. It's called "Spot the difference"
echo $now->format(DATE_COOKIE); // ዓርብ, 04-ግን-2009 02:09:52 EAT
echo $now->toGregorian()->format(DATE_COOKIE); // Friday, 12-May-2017 02:09:52 EAT
echo $now->format(DATE_ATOM); // 2009-09-04EAT02:09:52+03:00
echo $now->toGregorian()->format(DATE_ATOM); // 2017-05-12T02:09:52+03:00
echo $now->format('F j ቀን Y'); // ግንቦት 4 ቀን 2009
echo $now->toGregorian()->format('F j ቀን Y'); // May 12 ቀን 2017
echo $now->format('H:i:s A'); // 10:09:17 ረፋድ
echo $now->toGregorian()->format('H:i:s A'); // 10:09:17 AM
$easter = new Andegna\Holiday\Easter();
// እሑድ፣ ሚያዝያ 08 ቀን 00:00:00 እኩለ፡ሌሊት EAT 2009 ዓ/ም
echo $easter->get(2009)->format(Andegna\Constants::DATE_ETHIOPIAN).PHP_EOL;
// or just ...
foreach ([2006,2007,2008,2009,2010,2011,2012] as $year) {
echo $easter->get($year)->format(Andegna\Constants::DATE_ETHIOPIAN).PHP_EOL;
}
use Andegna\Validator\DateValidator;
// true
$is_valid1 = (new DateValidator(15,9, 2009))->isValid();
// false
$is_valid2 = (new DateValidator(6,13, 2009))->isValid();
use Andegna\Validator\LeapYearValidator;
// false
$is_valid3 = (new LeapYearValidator(2009))->isValid();
// true
$is_valid4 = (new LeapYearValidator(2007))->isValid();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.