PHP PROJECT

README.md

Panchang Calendar

This page provides daily panchang for most cities in the world. Tithi, Nakshtra, Sunrise, Sunset, Rahukaal, Yamghanda, Gulika...

Files


NameTypeSizeLast Modified
form.php phpfile icon 1611 04 February 2017 01:20:20
template.php phpfile icon 2622 04 February 2017 00:56:48
example.php phpfile icon 181 04 February 2017 01:46:30
moon directory icon 4096 31 March 2017 08:37:28
panchang_calendar_V1.php phpfile icon 15448 04 February 2017 22:15:30
cal.php phpfile icon 735 04 February 2017 00:50:10

Source

  1. <?php
  2. /*
  3. Version : 1.000
  4. Date: Sat, 4th Feb 2017 
  5. Panchang Calendar Version 1.0
  6. */
  7. Class panchang_calendar_V1{
  8.     function pc()
  9.     {
  10.     $nak=["अश्विनी","भरणी","कृत्तिका","रोहिणी","मृगशिरा","आर्द्रा","पुनर्वसु","पुष्य","आश्लेषा","माघ","पूर्वा फाल्गुनी","उत्तरा फाल्गुनी","हस्त","चित्रा","स्वाति","विशाखा","अनुराधा","ज्येष्ठ","मुल","पूर्व अषाढ","उत्तर आषाढ़","श्र‌ावण","धनिष्ठा","शतभिषा","पूर्वा भाद्रपद","उत्तरा  भाद्रपद","रेवती"];
  11.     $this->surya=["सूर्या उदय","सूर्या उस्त","राहुकाल","यमगंदा""गुलिक ""योग","करण"];
  12.     $week_name=["रविवार","सोमवार","मंगलवार","बुधवार","गुरुवार","शुक्रवार","शनिवार","रविवार"];
  13.     $karan=["बव","बालव","कौलव","तैतिल","गरज","वणिज","भद्रा","शकुनि","चतुष्पाद","नाग","किंस्तुघ्न"];
  14.     $ritu=["ग्रीष्म ऋतु","ग्रीष्म ऋतु","वर्षा-ऋतु","वर्षा-ऋतु","पतझड़","पतझड़","देर से शरद ऋतु","देर से शरद ऋतु","शीत  ऋतु","शीत  ऋतु","बसंत ऋतु","बसंत ऋतु"];
  15.     $yog=["विष्कंभ ","प्रीटी ","आयुष्मान"," सौभाग्य ","सोभन ","अतिगंड ","सुकर्म ","धरती ","सुला ","गन्दा ","व्रद्धि ","ध्रुव","व्याघात ","बरसाना","वज्र","सिद्धि","व्यतिपात ","वारियर्स ","परिघ ","शिव","सिद्धा","मध्य","शुभा","षुक्ल ","ब्रह्मा","महेंद्र","वैधृति "];
  16.     $month_name=[""," जनवरी"," फ़रवरी","मार्च","अप्रैल","मई","जून"," जुलाई","अगस्त"," सितंबर","अक्टूबर","नवंबर","दिसंबर"];
  17.     $months = array('January','February','March','April','May','June','July','August','September','October','November','December',);
  18.     $week_name = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
  19.      public $MaandiGunanka  = [26/30,22/30,18/30,14/30,10/30,6/30,2/30,30/30]; //In Weekday order; Take 5th for night time
  20. public $kaalachakra=[0,2,4,3,5,6,1,7]; //Kaalachakra sequence
  21. public $kaalachakra_start = [0,6,1,3,2,4,5];
  22. public $caughadia_start = [0,3,6,2,5,1,4];
  23. public $graha = ["Sun","Moon","Mars","Mercury","Jupiter","Venus","Saturn","Rahu","Ketu"]; //Normal Graha Sequence (Vara Sequence)
  24. public $caughadiya = ["Udvega-Su","Chara-Ve","Laabha-Me","Amrit-Mo","Kaala-Sa","Shubha-Ju","Roga-Ma"];
  25. public $muhurtha = ["Rudra-Ardra","Ahi-Aslesha","Mitra-Anuradha","Pitri-Magha","Vasu-Dhanishtha","Ambu-Purvashadha","Visvadeva-Uttarashadha","Abhijit/Vidhi-Abhijit","Vidhata/Satamuki-Rohini","Puruhuta-Jyeshtha","Indragni/Vahni-Visakha","Nirriti/Naktancara-Mula","Varuna/Udakanatha-Satabhisha","Aryaman-Uttaraphalguni","Bhaga-Purvaphalguni","Girisa-Ardra","Ajapada-Purvabhadrapada","Ahirbudhnya-Uttarabhadrapada","Pushan-Revati","Asvi-Asvini","Yama-Bharani","Agni-Krittika","Vidhaatri-Rohini","Chanda-Mrigasira","Aditi-Punarvasu","Jiiva-Pushya","Vishnu-Sravana","Arka-Hasta","Tvashtri-Chitra","Maruta-Svati"];
  26. public $week_days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
  27. public $hora = ["Sun","Venus","Mercury","Moon","Saturn","Jupiter","Mars"];
  28. public $GulikaChakra = ["Kaala","-","Mrityu","Ardhaprahara","Yamaghanta","-","Gulika","-"];
  29.     if(isset($_POST['task']) && $_POST['task'] == "65bb"){
  30.      $mon $_POST['month'];
  31.      $year $_POST['year'];
  32.      $lat $_POST['lat'];
  33.      $lon $_POST['lon'];
  34.      $this->date_time$year."-".$mon."-1";
  35.      $latitude=$lat;
  36.     $longitude=$lon;
  37.     }
  38.     else
  39.     {    
  40.     $mon =date("F");
  41.      $year date("Y");
  42.      $lat 28.7041;
  43.      $lon 77.1025;
  44.      $this->date_time$year."-".$mon."-1";
  45.      $latitude=$lat;
  46.     $longitude=$lon;
  47.     }
  48.     if($latitude < -90)
  49.     $latitude=$lat=28.7041;
  50.     if($latitude 90)
  51.     $latitude=$lat=28.7041
  52.     if($longitude 180.00)
  53.     $longitude=$lon=77.1025;
  54.     if($longitude < -180.00)
  55.     $longitude=$lon=77.1025;
  56.     $xp=new DateTime$this->date_time);
  57.     $chart=new stdClass;
  58.     $aadik=false;
  59.     $totalDay $xp->format("t");
  60.     $xx=new DateTime($this->date_time);
  61.     $xx->setDate($xp->format("Y"),$xp->format("m"),1);
  62.     $sss=date_sun_info($xx->getTimeStamp(), $latitude,$longitude);
  63.     for($i=1;$i<= $totalDay ;$i++){
  64.     $string file_get_contents("http://v23.in/bp-api-ephemeries/index.html?dt=".$xx->format("Y-m-d"));
  65.     $da json_decode($stringtrue);
  66.     if(isset($da['status']) && $da['status'] == 'OK'){
  67.     $chart->sun=$da['Sun'];
  68.     $chart->moon=$da['Moon'];
  69.     } 
  70.     else{
  71.     $chart->sun=0.0;
  72.     $chart->moon=0.0;
  73.     }
  74.     $sss=date_sun_info(strtotime($xx->format("Y-m-d")), $latitude,$longitude);
  75.     $data[$i]['tithi']='<span class="lead text-right text-danger">'.$this->getTithi($chart->moon,$chart->sun)."</span>";
  76.     if($xx->format("D") == "Sun"){
  77.     $data[$i]['day']='<p class="leh text-center">'.$week_name[$xx->format("w")].'<br><span class="hedh">'.$i.'</span><br>'.$month_name[$xx->format("n")].'<br>';
  78.     }
  79.     else{
  80.     $data[$i]['day']='<p class="le text-center">'.$week_name[$xx->format("w")].'<br><span class="hed">'.$i.'</span><br>'.$month_name[$xx->format("n")].'<br>';
  81.     }
  82.     $hindi =array("चैत्र","वैशाख","ज्येष्ठ","आषाढ़","श्रावण ","भाद्रपक्ष","आश्विन","कार्तिक","मार्गशीष","पौष","माघ","फाल्गुन","चैत्र");
  83.     $th=intval(fmod(360+$chart->moon $chart->sun,360)/12);
  84.     if(intval(fmod($chart->sun+6,30)) == 0){
  85. $data[$i]['img']="sun";
  86. $data[$i]['paksh']="Sakranti ".$hindi[intval(fmod($chart->sun+6,30))];
  87. if($th == 29)
  88. $aadik=true;
  89. }
  90.     else{
  91.     $data[$i]['img']=$th;
  92.     $data[$i]['paksh']=$this->getTithi($chart->moon,$chart->sun);
  93.     }
  94. $date_time=$xx->format("Y-m-d H:i:s");
  95.     if($aadik &&  $th 2){
  96.     $aadik=false;
  97.     $data[$i]['img']="aadik";
  98.     $data[$i]['paksh']=" aadik mass start ";    
  99.     }
  100.     $data[$i]['text']=$this->getNakshtra($chart->moon)."<br>".$this->surya[0]." ".date("h:i:A",$sss['sunrise'])."<br>".$this->surya[1]." ".date("h:i:A",$sss['sunset'])." ".$this->surya[2].": ".$this->getRahuKalam($date_time,$sss['sunrise'],$sss['sunset'])."<br>".$this->surya[3]." ".$this->getYamaganda($date_time,$sss['sunrise'],$sss['sunset'])."<br>".$this->surya[4]."  ".$this->getGulika($date_time,$sss['sunrise'],$sss['sunset']);    
  101.     $xx->add(new DateInterval("P1D"));
  102.     }
  103.     $arv=array("year"=>$year,"month"=>$mon,"lat"=>$latitude,"lon"=>$longitude,"filename"=>"panchang-calendar");    
  104.     $r=$this->render_temp("form.php",$arv);
  105.     $r=$this->render_temp("cal.php",array("form"=>$r,"data"=>$data,"day"=>$xp->format("D"),"year"=>$year,"month"=>$mon));
  106.     $output['leftcontent']="";
  107.     $output['maincontent']=$r;
  108.     if(is_file"template.php"))
  109.     echo $this->render_temp(   "template.php",array("output"=>$output));
  110.     unset($output);
  111.     }
  112.     public function render_temp($file$data = array()) {
  113.         if (file_exists($file)) {
  114.             extract($data);
  115.             ob_start();
  116.             require($file);
  117.             $out ob_get_contents();
  118.             ob_end_clean();
  119.             return $out;
  120.         } else {
  121.         return false;
  122.         }
  123.     }
  124.     function getMass($moon,$surya,$mass)
  125.     {
  126.     $hinduMonths = [
  127.     [0,4,349,19,"चैत्र"],
  128.     [1,34,19,49,"वैशाख"],
  129.     [2,64,49,79,"ज्येष्ठ"],
  130.     [3,94,79,109,"आषाढ़"],
  131.     [4,124,109,139,"श्रावण "],
  132.     [5,154,139,169,"भाद्रपक्ष"],
  133.     [6,184,169,199,"आश्विन"],
  134.     [7,214,199,229,"कार्तिक"],
  135.     [8,244,229,259,"मार्गशीष"],
  136.     [9,274,259,289,"पौष"],
  137.     [10,304,289,319,"माघ"],
  138.     [11,334,319,349,"फाल्गुन"],
  139.     [12,4,349,19,"चैत्र"],        
  140.     ];        
  141.     $th=fmod((360+$moon $surya),360)/12;
  142.     $th=intval($th);
  143.     if(intval($th)<15)
  144.     $tx "s";
  145.     else
  146.     $tx "k";
  147.     $ss=intval($surya 30);
  148.     $hindi =array("वैशाख","ज्येष्ठ","आषाढ़","श्रावण ","भाद्रपक्ष","आश्विन","कार्तिक","मार्गशीष","पौष","माघ","फाल्गुन","चैत्र");
  149.     $pak=array(" पक्ष "," कृष्णा "," शुक्ल  ");
  150.     $su=$surya 12;
  151.     $hindi[intval($surya/30)];
  152.     $pak=array(" पक्ष "," कृष्णा "," शुक्ल  ");
  153.     $th=fmod((360+$moon $surya),360)/12;
  154.     }    
  155.     
  156.     function getTithi($moon,$surya,$mass='')
  157.     {
  158.     $tithi = ["प्रतिपदा","द्वितीय","तृतीय","चतुर्थी ","पंचमी","षष्टी","सप्तमी","अष्टमी","नवमी","दसमी ","एकादशी","द्वादसी","त्रयोदसी","चतुर्दशी","पूर्णिमा"," प्रतिपदा","द्वितीय","तृतीय","चतुर्थी ","पंचमी","षष्टी","सप्तमी","अष्टमी","नवमी","दसमी ","एकादशी","द्वादसी","त्रयोदसी","चतुर्दशी","अमावस्या"];
  159.     $r=$surya;
  160.     $hindi =array("वैशाख","ज्येष्ठ","आषाढ़","श्रावण ","भाद्रपक्ष","आश्विन","कार्तिक","मार्गशीष","पौष","माघ","फाल्गुन","चैत्र");
  161.     $th=fmod(((360+$moon) - $surya),360)/12;
  162.     $th=intval($th);
  163.     if($th>=&& $th<15 )
  164.     $tx ="   शुक्ल  ".$tithi[$th];
  165.     else
  166.     $tx "     कृष्णा  ".$tithi[$th];
  167.     return $tx;
  168.     }
  169.     
  170.     function getMoonPhase($moon,$surya)
  171.     {
  172.     $tithi = ["New Moon","Moon +10%","Moon +20%","Moon +25%","Moon +30%","Moon +40%","Moon +45%","Moon +50%","Moon +55%","Moon +65%","Moon +75%","Moon +80%","Moon +90%","Moon +95%","Full Moon","Moon -5%","Moon -10%","Moon -20%","Moon -25%","Moon -30%","Moon -40%","Moon -45%","Moon -50%","Moon -55%","Moon -65%","Moon -75%","Moon -80%","Moon -90%","Moon -95%","Moon -100%"];
  173.     $th=fmod((360+$moon $surya),360)/12;
  174.     return $tithi[intval($th)];
  175.     }    
  176.     function getNakshtra($moon)
  177.     {
  178.     if($moon>13.33)
  179.     $r=($moon/13.33);
  180.     else
  181.     $r=1;
  182.     $nak=["अश्विनी","भरणी","कृत्तिका","रोहिणी","मृगशिरा","आर्द्रा","पुनर्वसु","पुष्य","आश्लेषा","माघ","पूर्वा फाल्गुनी","उत्तरा फाल्गुनी","हस्त","चित्रा","स्वाति","विशाखा","अनुराधा","ज्येष्ठ","मुल","पूर्व अषाढ","उत्तर आषाढ़","श्र‌ावण","धनिष्ठा","शतभिषा","पूर्वा भाद्रपद","उत्तरा  भाद्रपद","रेवती"];    
  183.     if(isset($nak[intval($r)]))
  184.     return "नक्षत्र :".$nak[intval($r)]; 
  185.     else
  186.     return "नक्षत्र :".$nak[1];     
  187.     }    
  188.     function getRahuKalam($date_time,$sr,$ss)
  189.     {
  190.     $kaalachakra_start = [0,6,1,3,2,4,5,0];
  191.     $r=($ss-$sr)/8;
  192.     $rr=array("Sunday"=>8,"Monday"=>2,"Tuesday"=>7,"Wednesday"=>5,"Thursday"=>6,"Friday"=>3,"Saturday"=>3);
  193.     return date("H:i",$rr[date("l",$sr)]*$r)." - ".date("H:i",$rr[date("l",$sr)]*$r+$r); 
  194.     }    
  195.     function getYamaganda($date_time,$sr,$ss)
  196.     {
  197.     $r=($ss-$sr)/8;
  198.     $rr=array("Sunday"=>5,"Monday"=>4,"Tuesday"=>3,"Wednesday"=>2,"Thursday"=>1,"Friday"=>6,"Saturday"=>7);
  199.     return date("H:i",$rr[date("l",$sr)]*$r $r)." - ".date("H:i",$rr[date("l",$sr)]*$r); 
  200.     }    
  201.     function getGulika($date_time,$sr,$ss)
  202.     {
  203.     $r=($ss-$sr)/8;
  204.     $rr=array("Sunday"=>7,"Monday"=>6,"Tuesday"=>5,"Wednesday"=>4,"Thursday"=>3,"Friday"=>2,"Saturday"=>1);
  205.     return date("H:i",$rr[date("l",$sr)]*$r $r)." - ".date("H:i",$rr[date("l",$sr)]*$r); 
  206.     }    
  207.     function getKaran($moon,$surya)
  208.     {
  209.     // hindi    $karana=["किंस्तुघ्न","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","बव","बालव","कौलव","तैतिल","गरज","वणिज","विष्टि ","शकुनि","चतुष्पाद","नाग","किंस्तुघ्न"];
  210.     $karana = ["Kimstugna","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Bhava","Bhaalava","Kaulava","Taitula","Garija","Vanija","Vishti","Shakuni","Chatushpada","Naaga"];
  211.     $th=fmod((360+$moon $surya),360)/72;
  212.     if(isset($karana[intval($th 2)]))
  213.     return $karana[intval($th 2)];
  214.     }
  215.     function getYoga($moon,$surya)
  216.     {
  217.     $yoga=["Vishkumbha","Priti","Ayushman","Saubhagya","Shobhan","Atiganda","Sukarma","Dhriti","Shula","Ganda","Vridhi","Dhruv","Vyaghata","Harshan","Vraj","Sidhi","Vyatipata","Variyana","Parigha","Shiva","Shidha","Sadhya","Shubha","Shukla","Bhramha","Indra","Vraidhiti","Vishkumbha"];
  218.     // hindi $yoga=["विष्कंभ ","प्रीटी ","आयुष्मान"," सौभाग्य ","सोभन ","अतिगंड ","सुकर्म ","धरती ","सुला ","गन्दा ","व्रद्धि ","ध्रुव","व्याघात ","बरसाना","वज्र","सिद्धि","व्यतिपात ","वारियर्स ","परिघ ","शिव","सिद्धा","मध्य","शुभा","षुक्ल ","ब्रह्मा","महेंद्र","वैधृति "];
  219.             
  220.     if(($moon $surya)>13.20)
  221.     $r fmod((360+$moon $surya),360)/13.20;
  222.     else
  223.     $r=0;
  224.     if(isset($yoga[intval($r)]))
  225.     return $yoga[intval($r)]; 
  226.     }    
  227.     
  228. }    

Demo

You can find a demo available here: panchang calendar

Requirment

  • mySql
  • PHP >= 5.4
  • Apache Server

Contribute

  • Vishv Sahdev

Example

  1. <?
  2. include "panchang_calendar_V1.php";
  3. define("LINK","http://localhost/panchang_calendar/");
  4. date_default_timezone_set('Asia/Kolkata');
  5. $n=new panchang_calendar_V1;
  6. $n->pc();

>>

Download