php 日历设置当月节假_php实现日历功能 周一至周日对应某年某月日期

在做很多程序时,需要日历选择功能,例如预约排班功能;

/**

* php生成日历功能

*/

class Calendar{

private $year;

private $month;

private $weeks  = array('日','一','二','三','四','五','六');

function __construct($options = array()) {

$this->year = date('Y');

$this->month = date('m');

$vars = get_class_vars(get_class($this));

foreach ($options as $key=>$value) {

if (array_key_exists($key, $vars)) {

$this->$key = $value;

}

}

}

function display()

{

echo '

//$this->showChangeDate();

$this->showWeeks();

$this->showDays($this->year,$this->month);

echo '

';

}

public function showWeeks()

{

$str =  '

';

foreach($this->weeks as $title)

{

$str.= '

'.$title.'';

}

$str.= '

';

return  $str;

}

public function showDays($is)

{

$year = $this->year;

$month = $this->month;

$firstDay = mktime(0, 0, 0, $month, 1, $year);

$starDay = date('w', $firstDay);

$days = date('t', $firstDay);

$str =  '

';

for ($i=0; $i

$str.= '

 ';

}

for ($j=1; $j<=$days; $j++) {

$i++;

if ($j == date('d')) {

if(in_array($j,$is)){

$class_ss = 'qiandao_2';

}else{

$class_ss = '';

}

$str.= '

'.$j.'';

} else {

if(in_array($j,$is)){

$class_ss = 'qiandao_1';

}else{

$class_ss = '';

}

$str.= '

'.$j.'';

}

if ($i % 7 == 0) {

$str.= '

';

}

}

$str.= '

';

return $str;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值