Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hello Bahaa,

 

To understand more about some unfamiliar calendars, First of all I introduce them

Two different calendars use as formal calendar in middle-east :

First : Lunar-Calendar(Hijri) - it uses by Muslims and Arabic countries. (As i write this post the lunar calendar is 1432,09,21)

Second: Sun-Calendar(Jalali) - it uses by Persian language countries like Iran, Turkmenistan, Afghanistan and other persian language countries.... (1390,05,31)

And other one is from China:

Third : Chinese Lunar Calendar - it used by Chinese people however maybe a little hard and I do not understand it but this year of Rabbit. (100,07,23)

I found a Gregorian Calender to Lunar Calendar converter is written by Tayeb Habib and source from www.redacacia.wordpress.com, email: tayeb.habib@gmail.com

 

 

021	// obtain month, today date etc
022	$month = (isset($month)) ? $month : date("n",time());
023	$monthnames = array("January","February","March","April","May","June","July","August","September","October","November","December");
024	$textmonth = $monthnames[$month - 1];
025	$year = (isset($year)) ? $year : date("Y",time());
026	$today = (isset($today))? $today : date("j", time());
027	$today = ($month == date("n",time())) ? $today : 32;
028	 
029	// The Names of Hijri months
030	$mname = array("Muharram","Safar","Rabi'ul Awal","Rabi'ul Akhir","Jamadil Awal","Jamadil Akhir","Rajab","Sha'ban","Ramadhan","Shawwal","Zul Qida","Zul Hijja"); 
031	// End of the names of Hijri months
032	 
033	// Setting how many days each month has
034	if ( (($month <8 ) && ($month % 2 == 1)) || (($month > 7) && ($month % 2 ==
035	0)) ) $days = 31;
036	if ( (($month <8 ) && ($month % 2 == 0)) || (($month > 7) && ($month % 2 ==
037	1)) )
038	$days = 30;
039	 
040	//checking leap year to adjust february days
041	if ($month == 2)
042	$days = (date("L",time())) ? 29 : 28;
043	 
044	$dayone = date("w",mktime(1,1,1,$month,1,$year));
045	$daylast = date("w",mktime(1,1,1,$month,$days,$year));
046	$middleday = intval(($days-1)/2);
047	 
048	//checking the hijri month on beginning of gregorian calendar
049	$date_hijri = date("$year-$month-1");
050	list ($HDays, $HMonths, $HYear) = Hijri($date_hijri);
051	$smon_hijridone = $mname[$HMonths-1];
052	$syear_hijridone = $HYear;
053	 
054	//checking the hijri month on end of gregorian calendar
055	$date_hijri = date("$year-$month-$days");
056	list ($HDays, $HMonths, $HYear) = Hijri($date_hijri);
057	$smon_hijridlast = $mname[$HMonths-1];
058	$syear_hijridlast = $HYear;
059	//checking the hijri month on middle of gregorian calendar
060	$date_hijri = date("$year-$month-$middleday");
061	list ($HDays, $HMonths, $HYear) = Hijri($date_hijri);
062	$smon_hijridmiddle = $mname[$HMonths-1];
063	$syear_hijridmiddle = $HYear;
064	 
065	// checking if there's a span of a year
066	if ($syear_hijridone == $syear_hijridlast) {
067	$syear_hijridone = "";
068	}
069	 
070	//checking if span of month is only one or two or three hijri months
071	if (($smon_hijridone == $smon_hijridmiddle) AND ($smon_hijridmiddle == $smon_hijridlast)) {
072	$smon_hijri = "<font color=red>".$smon_hijridone." ".$syear_hijridlast."</font>";
073	}
074	 
075	if (($smon_hijridone == $smon_hijridmiddle) AND ($smon_hijridmiddle != $smon_hijridlast)) {
076	$smon_hijri = "<font color=red>".$smon_hijridone." ".$syear_hijridone."-".$smon_hijridlast." ".$syear_hijridlast."</font>";  
077	}
078	if (($smon_hijridone != $smon_hijridmiddle) AND ($smon_hijridmiddle == $smon_hijridlast)) {
079	$smon_hijri = "<font color=red>".$smon_hijridone." ".$syear_hijridone."-".$smon_hijridlast." ".$syear_hijridlast."</font>";  
080	}
081	 
082	if (($smon_hijridone != $smon_hijridmiddle) AND ($smon_hijridmiddle != $smon_hijridlast)) {
083	$smon_hijri = "<font color=red>".$smon_hijridone." ".$syear_hijridone."-"."-".$smon_hijridmiddle."-".$smon_hijridlast." ".$syear_hijridlast."</font>";  
084	}
085	?>

 

 

I hope it is useful article.

  • Upvote 2
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...