我有两个日期:
2014年11月11日和2014年11月17日
现在我想了解这两者之间的所有日期。
然后我需要在日历中检查它,如果它在日历中,我需要用红色着色
我该怎么做?
这是我的日历代码: -
<Table class="grayBg" align="center" style="font-family: 'trebuchet MS';font-size:12px" width="288">
<caption style="font-weight:bold;padding-bottom:2px" class="black font10px">
<?php
if(file_exists('winneradmincpanel/connect.php'))
{
require_once('winneradmincpanel/connect.php');
$connect = new connect();
include 'config.php';
require_once('date/hjreedate.php');
$hijri = new HijriCalendar();
include('date/hdate.php');
$date = $hijri -> GregorianToHijri(time());
$hdate = $aday." ".$date[1].' '.$hijri ->monthName($date[0]).' '.$date[2] ." هـ";
/// get current month and year and store them in $cMonth and $cYear variables
(intval($_REQUEST["month"])>0) ? $cMonth = intval($_REQUEST["month"]) : $cMonth = date("m");
(intval($_REQUEST["year"])>0) ? $cYear = intval($_REQUEST["year"]) : $cYear = date("Y");
echo GregorianHijri::getMonthName ( $m,GregorianHijri::$GREGORIAN,$GLOBALS['lang']) . ' ' . $a;
// generate an array with all dates with events
?>
</caption>
<tr style="background:#CCCCCC">
<th>الاثنين</th>
<th>الثلاثاء</th>
<th>الاربعاء</th>
<th>الخميس</th>
<th>الجمعة</th>
<th>السبت</th>
<th>الاحد</th>
</tr>
<?php
$ts = mktime ( 1, 0, 0, $m, 1, $a );
$detail = getdate ( $ts );
echo "<tr>";
if ($detail ['wday'] == 0)
$nb = 6;
else
$nb = $detail ['wday'] - 1;
for($j = 1; $j <= $nb; $j ++)
echo "<td>";
$n = $detail ['wday'];
$valid = TRUE;
$j = 1;
$monthsArray = array();
do {
$valid = checkdate ( $m, $j, $a );
if ($valid) {
//$dateOutput = "$a-$m-$j";
$dateOutput = sprintf ( $GLOBALS['gregorianDateFormat'], $a,$m,$j);
$hijriDay = GregorianHijri::hijriDay($a,$m,$j,$GLOBALS['lang']);
$explod = explode("-",$hijriDay);
$year = $explod[1];
$day = $explod[0];
$hijriDate = GregorianHijri::hijriDate($a,$m,$j,$GLOBALS['lang'],$GLOBALS['hijriDateFormat']);
$hijriMonth = GregorianHijri::hijriMonth($a,$m,$j,$GLOBALS['lang']);
array_push($monthsArray,$hijriMonth);
$sql = "SELECT * FROM tarshoh WHERE `datedurationm`";
$sql_result = mysql_query ($sql) or die ('request "Could not execute SQL query" '.$sql);
while ($row = mysql_fetch_assoc($sql_result)) {
$events[$row["event_date"]]["dawracat"] = $row["dawracat"];
$events[$row["event_date"]]["datedurationm"] = $row["datedurationm"];
}
$currntm = $events[$row["event_date"]]["datedurationm"];
$currnth = $events[$row["event_date"]]["datedurationh"];
if(!isset($_REQUEST['day'])){
if($j == $currntm){
$bg = "#79c04b";
}else{
$bg = "";
}
}else{
if($j == $newDay){
//$bg = "#cccccc";
}else{
//$bg = "";
}
}
///////////////////////
$gregorianId = 'gregorianDate'.$j;
$hijriId = 'hijriDate'.$j;
$function = "getDateInputs('".$gregorianId."','".$hijriId."')";
if (($j + $nb) % 7 == 1)
echo "<tr>";
echo "<td align=center style='font-size:10px;cursor:pointer' bgcolor='$bg' onclick=$function class='cel-calendar-border'>
<table border='0' class='font10px' width='30' cellspacing='0' cellpadding='0' >
<tr><td align='left'><span class='black'>$j</span></td></tr>
<tr><td align='right' class='red'>$day</td></tr></table>";
echo "<input type='hidden' name=$gregorianId id =$gregorianId value='$dateOutput'>";
echo "<input type='hidden' name=$hijriId id =$hijriId value='$hijriDate'>";
$j = $j+1;
echo "</td>";
}
} while ($valid);
$monthsArray = array_unique($monthsArray);
?>
</TABLE>
<div align="center" style="font-size:10px;font-family:'trebuchet MS';padding-top:2px;padding-bottom:2px;font-weight:bold" class="red">
<?php
$i=0;
foreach ($monthsArray as $key=> $value){
$i++;
echo $value;
if ($i < count($monthsArray)){
echo " / ";
}
}
echo " ".$year;
}
?>
</div>
我通过这个查询得到了这个拖曳日期: -
$sql = "SELECT * FROM tarshoh WHERE `datedurationm`";
$sql_result = mysql_query ($sql) or die ('request "Could not execute SQL query" '.$sql);
while ($row = mysql_fetch_assoc($sql_result)) {
$events[$row["event_date"]]["datestartm"] = $row["datestartm"];
$events[$row["event_date"]]["dateendm"] = $row["dateendm"];
}
这里的日历: -
echo "<tr>";
echo "<td align=center style='font-size:10px;cursor:pointer' bgcolor='$bg' onclick=$function class='cel-calendar-border'>
<table border='0' class='font10px' width='30' cellspacing='0' cellpadding='0' >
<tr><td align='left'><span class='black'>$j</span></td></tr>
<tr><td align='right' class='red'>$day</td></tr></table>";
echo "<input type='hidden' name=$gregorianId id =$gregorianId value='$dateOutput'>";
echo "<input type='hidden' name=$hijriId id =$hijriId value='$hijriDate'>";
$j = $j+1;
echo "</td>";