month == 12){ $this->nMonth = 1; $this->nYear = $this->year + 1; } else { $this->nMonth = $this->month + 1; $this->nYear = $this->year; } $this->nTimestamp = mktime(0,0,0,$this->nMonth,1,$this->nYear); } private function setPrev(){ if($this->month == 1){ $this->pMonth = 12; $this->pYear = $this->year - 1; } else { $this->pMonth = $this->month - 1; $this->pYear = $this->year; } $this->pTimestamp = mktime(0,0,0,$this->pMonth,1,$this->pYear); } private function getFirstDay(){ return date("w",mktime(0,0,0,$this->month,1,$this->year)); } public function __construct($timestamp){ $this->timestamp = $timestamp; $this->month = date("n",$this->timestamp); $this->year = date("Y",$this->timestamp); $this->setNext(); $this->setPrev(); $this->printCalendar(); } public function printCalendar(){ $this->build = '
| S | '; $this->build .= 'M | '; $this->build .= 'T | '; $this->build .= 'W | '; $this->build .= 'T | '; $this->build .= 'F | '; $this->build .= 'S | '; $this->build .= '
|---|---|---|---|---|---|---|
| pTimestamp).'" colspan="3" id="prev">« '.date("M",$this->pTimestamp).' | '; $this->build .= ''; $this->build .= ' | nTimestamp).'" colspan="3" id="next">'.date("M",$this->nTimestamp).' » | '; $this->build .= '||||
| '.($start + 1).' | '; $genCounter++; } $today = mktime(0,0,0,date("n"),date("j"),date("Y"));; for($d=1;$d<=$totalDays;$d++){ if(mktime(0,0,0,$this->month,$d,$this->year) == $today){ $this->build .= ''.$d.' | '; } else { $this->build .= ''.$d.' | '; } if($genCounter % 7 == 0 && $d != $totalDays){ $this->build .= '||||
| '.$start.' | '; $start++; $genCounter++; } $this->build .= '