PHP code example of bahaicalendar / badical

1. Go to this page and download the library: Download bahaicalendar/badical 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/ */

    

bahaicalendar / badical example snippets


$badiDate = 
	\BahaiCalendar\BadiCal\Convert::GregorianToBadi(
		2015, //Gregorian year 
		3,    //Gregorian month
		21,   //Gregorian date,
		true  //TRUE = start of, FALSE/Omited = end of  
	);
echo $badiDate->monthName().' '.$badiDate->day().', '.$badiDate->year()."\n";
echo 'Date type: '.$badiDate->type."\n";

$badiDate = 
	\BahaiCalendar\BadiCal\Convert::GregorianToBadi(
		2015, //Gregorian year 
		3,    //Gregorian month
		21,   //Gregorian date,
		FALSE  //Note the difference
	);
echo $badiDate->year().'-'.$badiDate->month(true /* add zero */).'-'.$badiDate->day(true /* add zero */)."\n";

$gregDate = 
	\BahaiCalendar\BadiCal\Convert::BadiToGregorian(
		172, //Badi year 
		1,    //Badi month
		1,   //Badi date,
		true  //TRUE = start of, FALSE/Omited = end of  
	);
echo $gregDate->monthName().' '.$gregDate->day().', '.$gregDate->year()."\n";
echo 'Date type: '.$gregDate->type."\n";

$gregDate = 
	\BahaiCalendar\BadiCal\Convert::BadiToGregorian(
		172, //Badi year 
		1,    //Badi month
		1,   //Badi date,
		FALSE  //Note the difference
	);
echo $gregDate->year().'-'.$gregDate->month(true /* add zero */).'-'.$gregDate->day(true /* add zero */)."\n";

Baha 2, 172
Date type: BADI
172-01-01

March 20, 2015
Date type: GREGORIAN
2015-03-21

php test.php /path/to/BadiTest/Basic.json