views:

91

answers:

4

Hi i want to insert php calendar to my page .. which is the best way to do it

A: 
Mr Roys
+1  A: 

If it makes your life easier, you can embed a Google calendar.

--EDIT--
Well, according to the tags on the post - which i only noticed now - your question is about how to add a calendar using CodeIgnniter.
Here:

$this->load->library('calendar');

echo $this->calendar->generate();
Jorge
A: 

the faster way is, if you have linux server, by calling:

<?php
exec("/usr/bin/cal -h", $buff);
echo "<pre>".implode("\n", $buff)."</pre>";
?>
silent
+1  A: 

using this function i can calculated the first day of the month and last date of the month and filed the date with these parameters

function phpcal()
    {
        //$month=05;
        //$day=01;
        $cur_date = date('d-m-Y');
        list($day,$month,$year) = explode("-", $cur_date);



        //$year=2014;
         //$month = $this->input->post('monthnum');
        // $year = $this->input->post('yrnum');
         $zeroCnt = date("w", mktime(0,0,0,$month,$day,$year)); 
         $lastDay = date("t", strtotime($year . "-" . $month . "-01"));
        $tempArr = array('0'=>'January','1'=>'February','2'=>"March", '3'=>"April",'4'=>"May",'5'=>"June",'6'=>"July",
        '7'=>"August",'8'=>"September",'9'=>"October",'10'=>"November",'11'=>"December");
        if( (!empty($month)) && (!empty($year)) )
        {
            $cal[0] = $month+1;
            $cal[1] = $year;
            //$cal[2] = $tempArr[$month-1];
            $month-1;
            $data['cal'] = $cal;
        }
        // "March", "April","May","June","July","August","September","November","December"];
        for($i=0;$i<$zeroCnt;$i++)
        {
            $dateArr[$i] = 0;
        }

        for($j=1,$i=$zeroCnt;$j<=$lastDay;$i++,$j++)
        {
            $dateArr[$i] = $j ;         
        }
        $data['zeroCnt'] = $zeroCnt;
        $data['lastDay'] = $lastDay;
        $data['dateArr'] = $dateArr;
        $data['month'] = $month;
        $data['year'] = $year;

        $this->load->view('phpcal',$data);


    }
udaya