突出显示PHP日历中的当前日期

时间:2015-08-25 13:07:49

标签: php html calendar

我正在使用此网站的日历代码:

http://www.startutorial.com/articles/view/how-to-build-a-web-calendar-in-php

您如何突出当天?

我试图在

中添加其他变量
private function _showDay($cellNumber){
    $today = date('Y-m-d');

然后

if($this->currentDate == '{$today}') { //DO SOMETHING }

我在考虑创建一个带边框或使用不同背景颜色的新CSS类。但它可能与已定义的类重复,例如' start'或者'结束'。

任何想法如何解决这个问题?我想保持简单,如果可能的话不要使用JavaScript。

1 个答案:

答案 0 :(得分:0)

在网页的评论部分找到它。

简明版:

创建一个新的样式元素

div#calendar ul.dates li.this_today { background-color: black; color: white; }

变化

private function _showDay($cellNumber){

并添加:

$today_day = date("d");
$today_mon = date("m");
$today_yea = date("Y");

$class_day = ($cellContent == $today_day && $this->currentMonth == $today_mon && $this->currentYear == $today_yea ? "this_today" : "nums_days");
return '<li class="' . $class_day . '">' . $cellContent . '</li>' . "\r\n";